summaryrefslogtreecommitdiff
path: root/base/win
diff options
context:
space:
mode:
Diffstat (limited to 'base/win')
-rw-r--r--base/win/event_trace_consumer.h150
-rw-r--r--base/win/scoped_co_mem.h68
-rw-r--r--base/win/scoped_com_initializer.h79
-rw-r--r--base/win/scoped_comptr.h168
-rw-r--r--base/win/scoped_gdi_object.h45
-rw-r--r--base/win/scoped_handle_test_dll.cc125
-rw-r--r--base/win/scoped_hdc.h78
-rw-r--r--base/win/scoped_hglobal.h53
-rw-r--r--base/win/scoped_propvariant.h58
-rw-r--r--base/win/scoped_select_object.h43
-rw-r--r--base/win/windows_version_unittest.cc22
11 files changed, 0 insertions, 889 deletions
diff --git a/base/win/event_trace_consumer.h b/base/win/event_trace_consumer.h
deleted file mode 100644
index 9f97e0df65..0000000000
--- a/base/win/event_trace_consumer.h
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// Declaration of a Windows event trace consumer base class.
-#ifndef BASE_WIN_EVENT_TRACE_CONSUMER_H_
-#define BASE_WIN_EVENT_TRACE_CONSUMER_H_
-
-#include <windows.h>
-#include <wmistr.h>
-#include <evntrace.h>
-#include <stddef.h>
-#include <vector>
-
-#include "base/macros.h"
-
-namespace base {
-namespace win {
-
-// This class is a base class that makes it easier to consume events
-// from realtime or file sessions. Concrete consumers need to subclass
-// a specialization of this class and override the ProcessEvent and/or
-// the ProcessBuffer methods to implement the event consumption logic.
-// Usage might look like:
-// class MyConsumer: public EtwTraceConsumerBase<MyConsumer, 1> {
-// protected:
-// static VOID WINAPI ProcessEvent(PEVENT_TRACE event);
-// };
-//
-// MyConsumer consumer;
-// consumer.OpenFileSession(file_path);
-// consumer.Consume();
-template <class ImplClass>
-class EtwTraceConsumerBase {
- public:
- // Constructs a closed consumer.
- EtwTraceConsumerBase() {
- }
-
- ~EtwTraceConsumerBase() {
- Close();
- }
-
- // Opens the named realtime session, which must be existent.
- // Note: You can use OpenRealtimeSession or OpenFileSession
- // to open as many as MAXIMUM_WAIT_OBJECTS (63) sessions at
- // any one time, though only one of them may be a realtime
- // session.
- HRESULT OpenRealtimeSession(const wchar_t* session_name);
-
- // Opens the event trace log in "file_name", which must be a full or
- // relative path to an existing event trace log file.
- // Note: You can use OpenRealtimeSession or OpenFileSession
- // to open as many as kNumSessions at any one time.
- HRESULT OpenFileSession(const wchar_t* file_name);
-
- // Consume all open sessions from beginning to end.
- HRESULT Consume();
-
- // Close all open sessions.
- HRESULT Close();
-
- protected:
- // Override in subclasses to handle events.
- static void ProcessEvent(EVENT_TRACE* event) {
- }
- // Override in subclasses to handle buffers.
- static bool ProcessBuffer(EVENT_TRACE_LOGFILE* buffer) {
- return true; // keep going
- }
-
- protected:
- // Currently open sessions.
- std::vector<TRACEHANDLE> trace_handles_;
-
- private:
- // These delegate to ImplClass callbacks with saner signatures.
- static void WINAPI ProcessEventCallback(EVENT_TRACE* event) {
- ImplClass::ProcessEvent(event);
- }
- static ULONG WINAPI ProcessBufferCallback(PEVENT_TRACE_LOGFILE buffer) {
- return ImplClass::ProcessBuffer(buffer);
- }
-
- DISALLOW_COPY_AND_ASSIGN(EtwTraceConsumerBase);
-};
-
-template <class ImplClass> inline
-HRESULT EtwTraceConsumerBase<ImplClass>::OpenRealtimeSession(
- const wchar_t* session_name) {
- EVENT_TRACE_LOGFILE logfile = {};
- logfile.LoggerName = const_cast<wchar_t*>(session_name);
- logfile.LogFileMode = EVENT_TRACE_REAL_TIME_MODE;
- logfile.BufferCallback = &ProcessBufferCallback;
- logfile.EventCallback = &ProcessEventCallback;
- logfile.Context = this;
- TRACEHANDLE trace_handle = ::OpenTrace(&logfile);
- if (reinterpret_cast<TRACEHANDLE>(INVALID_HANDLE_VALUE) == trace_handle)
- return HRESULT_FROM_WIN32(::GetLastError());
-
- trace_handles_.push_back(trace_handle);
- return S_OK;
-}
-
-template <class ImplClass> inline
-HRESULT EtwTraceConsumerBase<ImplClass>::OpenFileSession(
- const wchar_t* file_name) {
- EVENT_TRACE_LOGFILE logfile = {};
- logfile.LogFileName = const_cast<wchar_t*>(file_name);
- logfile.BufferCallback = &ProcessBufferCallback;
- logfile.EventCallback = &ProcessEventCallback;
- logfile.Context = this;
- TRACEHANDLE trace_handle = ::OpenTrace(&logfile);
- if (reinterpret_cast<TRACEHANDLE>(INVALID_HANDLE_VALUE) == trace_handle)
- return HRESULT_FROM_WIN32(::GetLastError());
-
- trace_handles_.push_back(trace_handle);
- return S_OK;
-}
-
-template <class ImplClass> inline
-HRESULT EtwTraceConsumerBase<ImplClass>::Consume() {
- ULONG err = ::ProcessTrace(&trace_handles_[0],
- static_cast<ULONG>(trace_handles_.size()),
- NULL,
- NULL);
- return HRESULT_FROM_WIN32(err);
-}
-
-template <class ImplClass> inline
-HRESULT EtwTraceConsumerBase<ImplClass>::Close() {
- HRESULT hr = S_OK;
- for (size_t i = 0; i < trace_handles_.size(); ++i) {
- if (NULL != trace_handles_[i]) {
- ULONG ret = ::CloseTrace(trace_handles_[i]);
- trace_handles_[i] = NULL;
-
- if (FAILED(HRESULT_FROM_WIN32(ret)))
- hr = HRESULT_FROM_WIN32(ret);
- }
- }
- trace_handles_.clear();
-
- return hr;
-}
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_EVENT_TRACE_CONSUMER_H_
diff --git a/base/win/scoped_co_mem.h b/base/win/scoped_co_mem.h
deleted file mode 100644
index a3737dd571..0000000000
--- a/base/win/scoped_co_mem.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_WIN_SCOPED_CO_MEM_H_
-#define BASE_WIN_SCOPED_CO_MEM_H_
-
-#include <objbase.h>
-
-#include "base/logging.h"
-#include "base/macros.h"
-
-namespace base {
-namespace win {
-
-// Simple scoped memory releaser class for COM allocated memory.
-// Example:
-// base::win::ScopedCoMem<ITEMIDLIST> file_item;
-// SHGetSomeInfo(&file_item, ...);
-// ...
-// return; <-- memory released
-template<typename T>
-class ScopedCoMem {
- public:
- ScopedCoMem() : mem_ptr_(NULL) {}
- ~ScopedCoMem() {
- Reset(NULL);
- }
-
- T** operator&() { // NOLINT
- DCHECK(mem_ptr_ == NULL); // To catch memory leaks.
- return &mem_ptr_;
- }
-
- operator T*() {
- return mem_ptr_;
- }
-
- T* operator->() {
- DCHECK(mem_ptr_ != NULL);
- return mem_ptr_;
- }
-
- const T* operator->() const {
- DCHECK(mem_ptr_ != NULL);
- return mem_ptr_;
- }
-
- void Reset(T* ptr) {
- if (mem_ptr_)
- CoTaskMemFree(mem_ptr_);
- mem_ptr_ = ptr;
- }
-
- T* get() const {
- return mem_ptr_;
- }
-
- private:
- T* mem_ptr_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedCoMem);
-};
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_SCOPED_CO_MEM_H_
diff --git a/base/win/scoped_com_initializer.h b/base/win/scoped_com_initializer.h
deleted file mode 100644
index 8efff856f0..0000000000
--- a/base/win/scoped_com_initializer.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_WIN_SCOPED_COM_INITIALIZER_H_
-#define BASE_WIN_SCOPED_COM_INITIALIZER_H_
-
-#include <objbase.h>
-
-#include "base/logging.h"
-#include "base/macros.h"
-#include "build/build_config.h"
-
-namespace base {
-namespace win {
-
-// Initializes COM in the constructor (STA or MTA), and uninitializes COM in the
-// destructor.
-//
-// WARNING: This should only be used once per thread, ideally scoped to a
-// similar lifetime as the thread itself. You should not be using this in
-// random utility functions that make COM calls -- instead ensure these
-// functions are running on a COM-supporting thread!
-class ScopedCOMInitializer {
- public:
- // Enum value provided to initialize the thread as an MTA instead of STA.
- enum SelectMTA { kMTA };
-
- // Constructor for STA initialization.
- ScopedCOMInitializer() {
- Initialize(COINIT_APARTMENTTHREADED);
- }
-
- // Constructor for MTA initialization.
- explicit ScopedCOMInitializer(SelectMTA mta) {
- Initialize(COINIT_MULTITHREADED);
- }
-
- ~ScopedCOMInitializer() {
-#ifndef NDEBUG
- // Using the windows API directly to avoid dependency on platform_thread.
- DCHECK_EQ(GetCurrentThreadId(), thread_id_);
-#endif
- if (succeeded())
- CoUninitialize();
- }
-
- bool succeeded() const { return SUCCEEDED(hr_); }
-
- private:
- void Initialize(COINIT init) {
-#ifndef NDEBUG
- thread_id_ = GetCurrentThreadId();
-#endif
- hr_ = CoInitializeEx(NULL, init);
-#ifndef NDEBUG
- if (hr_ == S_FALSE)
- LOG(ERROR) << "Multiple CoInitialize() calls for thread " << thread_id_;
- else
- DCHECK_NE(RPC_E_CHANGED_MODE, hr_) << "Invalid COM thread model change";
-#endif
- }
-
- HRESULT hr_;
-#ifndef NDEBUG
- // In debug builds we use this variable to catch a potential bug where a
- // ScopedCOMInitializer instance is deleted on a different thread than it
- // was initially created on. If that ever happens it can have bad
- // consequences and the cause can be tricky to track down.
- DWORD thread_id_;
-#endif
-
- DISALLOW_COPY_AND_ASSIGN(ScopedCOMInitializer);
-};
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_SCOPED_COM_INITIALIZER_H_
diff --git a/base/win/scoped_comptr.h b/base/win/scoped_comptr.h
deleted file mode 100644
index 9442672054..0000000000
--- a/base/win/scoped_comptr.h
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_WIN_SCOPED_COMPTR_H_
-#define BASE_WIN_SCOPED_COMPTR_H_
-
-#include <unknwn.h>
-
-#include "base/logging.h"
-#include "base/memory/ref_counted.h"
-
-namespace base {
-namespace win {
-
-// A fairly minimalistic smart class for COM interface pointers.
-// Uses scoped_refptr for the basic smart pointer functionality
-// and adds a few IUnknown specific services.
-template <class Interface, const IID* interface_id = &__uuidof(Interface)>
-class ScopedComPtr : public scoped_refptr<Interface> {
- public:
- // Utility template to prevent users of ScopedComPtr from calling AddRef
- // and/or Release() without going through the ScopedComPtr class.
- class BlockIUnknownMethods : public Interface {
- private:
- STDMETHOD(QueryInterface)(REFIID iid, void** object) = 0;
- STDMETHOD_(ULONG, AddRef)() = 0;
- STDMETHOD_(ULONG, Release)() = 0;
- };
-
- typedef scoped_refptr<Interface> ParentClass;
-
- ScopedComPtr() {
- }
-
- explicit ScopedComPtr(Interface* p) : ParentClass(p) {
- }
-
- ScopedComPtr(const ScopedComPtr<Interface, interface_id>& p)
- : ParentClass(p) {
- }
-
- ~ScopedComPtr() {
- // We don't want the smart pointer class to be bigger than the pointer
- // it wraps.
- static_assert(
- sizeof(ScopedComPtr<Interface, interface_id>) == sizeof(Interface*),
- "ScopedComPtrSize");
- }
-
- // Explicit Release() of the held object. Useful for reuse of the
- // ScopedComPtr instance.
- // Note that this function equates to IUnknown::Release and should not
- // be confused with e.g. unique_ptr::release().
- void Release() {
- if (this->ptr_ != NULL) {
- this->ptr_->Release();
- this->ptr_ = NULL;
- }
- }
-
- // Sets the internal pointer to NULL and returns the held object without
- // releasing the reference.
- Interface* Detach() {
- Interface* p = this->ptr_;
- this->ptr_ = NULL;
- return p;
- }
-
- // Accepts an interface pointer that has already been addref-ed.
- void Attach(Interface* p) {
- DCHECK(!this->ptr_);
- this->ptr_ = p;
- }
-
- // Retrieves the pointer address.
- // Used to receive object pointers as out arguments (and take ownership).
- // The function DCHECKs on the current value being NULL.
- // Usage: Foo(p.Receive());
- Interface** Receive() {
- DCHECK(!this->ptr_) << "Object leak. Pointer must be NULL";
- return &this->ptr_;
- }
-
- // A convenience for whenever a void pointer is needed as an out argument.
- void** ReceiveVoid() {
- return reinterpret_cast<void**>(Receive());
- }
-
- template <class Query>
- HRESULT QueryInterface(Query** p) {
- DCHECK(p != NULL);
- DCHECK(this->ptr_ != NULL);
- // IUnknown already has a template version of QueryInterface
- // so the iid parameter is implicit here. The only thing this
- // function adds are the DCHECKs.
- return this->ptr_->QueryInterface(p);
- }
-
- // QI for times when the IID is not associated with the type.
- HRESULT QueryInterface(const IID& iid, void** obj) {
- DCHECK(obj != NULL);
- DCHECK(this->ptr_ != NULL);
- return this->ptr_->QueryInterface(iid, obj);
- }
-
- // Queries |other| for the interface this object wraps and returns the
- // error code from the other->QueryInterface operation.
- HRESULT QueryFrom(IUnknown* object) {
- DCHECK(object != NULL);
- return object->QueryInterface(Receive());
- }
-
- // Convenience wrapper around CoCreateInstance
- HRESULT CreateInstance(const CLSID& clsid, IUnknown* outer = NULL,
- DWORD context = CLSCTX_ALL) {
- DCHECK(!this->ptr_);
- HRESULT hr = ::CoCreateInstance(clsid, outer, context, *interface_id,
- reinterpret_cast<void**>(&this->ptr_));
- return hr;
- }
-
- // Checks if the identity of |other| and this object is the same.
- bool IsSameObject(IUnknown* other) {
- if (!other && !this->ptr_)
- return true;
-
- if (!other || !this->ptr_)
- return false;
-
- ScopedComPtr<IUnknown> my_identity;
- QueryInterface(my_identity.Receive());
-
- ScopedComPtr<IUnknown> other_identity;
- other->QueryInterface(other_identity.Receive());
-
- return my_identity == other_identity;
- }
-
- // Provides direct access to the interface.
- // Here we use a well known trick to make sure we block access to
- // IUnknown methods so that something bad like this doesn't happen:
- // ScopedComPtr<IUnknown> p(Foo());
- // p->Release();
- // ... later the destructor runs, which will Release() again.
- // and to get the benefit of the DCHECKs we add to QueryInterface.
- // There's still a way to call these methods if you absolutely must
- // by statically casting the ScopedComPtr instance to the wrapped interface
- // and then making the call... but generally that shouldn't be necessary.
- BlockIUnknownMethods* operator->() const {
- DCHECK(this->ptr_ != NULL);
- return reinterpret_cast<BlockIUnknownMethods*>(this->ptr_);
- }
-
- // Pull in operator=() from the parent class.
- using scoped_refptr<Interface>::operator=;
-
- // static methods
-
- static const IID& iid() {
- return *interface_id;
- }
-};
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_SCOPED_COMPTR_H_
diff --git a/base/win/scoped_gdi_object.h b/base/win/scoped_gdi_object.h
deleted file mode 100644
index 9d8465b25b..0000000000
--- a/base/win/scoped_gdi_object.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_WIN_SCOPED_GDI_OBJECT_H_
-#define BASE_WIN_SCOPED_GDI_OBJECT_H_
-
-#include <windows.h>
-
-#include "base/scoped_generic.h"
-
-namespace base {
-namespace win {
-
-namespace internal {
-
-template <class T>
-struct ScopedGDIObjectTraits {
- static T InvalidValue() { return nullptr; }
- static void Free(T object) { DeleteObject(object); }
-};
-
-// An explicit specialization for HICON because we have to call DestroyIcon()
-// instead of DeleteObject() for HICON.
-template <>
-void inline ScopedGDIObjectTraits<HICON>::Free(HICON icon) {
- DestroyIcon(icon);
-}
-
-} // namespace internal
-
-// Like ScopedHandle but for GDI objects.
-template <class T>
-using ScopedGDIObject = ScopedGeneric<T, internal::ScopedGDIObjectTraits<T>>;
-
-// Typedefs for some common use cases.
-typedef ScopedGDIObject<HBITMAP> ScopedBitmap;
-typedef ScopedGDIObject<HRGN> ScopedRegion;
-typedef ScopedGDIObject<HFONT> ScopedHFONT;
-typedef ScopedGDIObject<HICON> ScopedHICON;
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_SCOPED_GDI_OBJECT_H_
diff --git a/base/win/scoped_handle_test_dll.cc b/base/win/scoped_handle_test_dll.cc
deleted file mode 100644
index 0d70c0b627..0000000000
--- a/base/win/scoped_handle_test_dll.cc
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <windows.h>
-
-#include <vector>
-
-#include "base/win/base_features.h"
-#include "base/win/current_module.h"
-#include "base/win/scoped_handle.h"
-
-namespace base {
-namespace win {
-namespace testing {
-
-extern "C" bool __declspec(dllexport) RunTest();
-
-namespace {
-
-struct ThreadParams {
- HANDLE ready_event;
- HANDLE start_event;
-};
-
-// Note, this must use all native functions to avoid instantiating the
-// ActiveVerifier. e.g. can't use base::Thread or even base::PlatformThread.
-DWORD __stdcall ThreadFunc(void* params) {
- ThreadParams* thread_params = reinterpret_cast<ThreadParams*>(params);
- HANDLE handle = ::CreateMutex(nullptr, false, nullptr);
-
- ::SetEvent(thread_params->ready_event);
- ::WaitForSingleObject(thread_params->start_event, INFINITE);
- ScopedHandle handle_holder(handle);
- return 0;
-}
-
-bool InternalRunThreadTest() {
- std::vector<HANDLE> threads_;
- // From manual testing, the bug fixed by crrev.com/678736a starts reliably
- // causing handle verifier asserts to trigger at around 100 threads, so make
- // it 200 to be sure to detect any future regressions.
- const size_t kNumThreads = 200;
-
- // bManualReset is set to true to allow signalling multiple threads.
- HANDLE start_event = ::CreateEvent(nullptr, true, false, nullptr);
- if (!start_event)
- return false;
-
- HANDLE ready_event = CreateEvent(nullptr, false, false, nullptr);
- if (!ready_event)
- return false;
-
- ThreadParams thread_params = { ready_event, start_event };
-
- for (size_t i = 0; i < kNumThreads; i++) {
- HANDLE thread_handle =
- ::CreateThread(nullptr, 0, ThreadFunc,
- reinterpret_cast<void*>(&thread_params), 0, nullptr);
- if (!thread_handle)
- break;
- ::WaitForSingleObject(ready_event, INFINITE);
- threads_.push_back(thread_handle);
- }
-
- ::CloseHandle(ready_event);
-
- if (threads_.size() != kNumThreads) {
- for (auto* thread : threads_)
- ::CloseHandle(thread);
- ::CloseHandle(start_event);
- return false;
- }
-
- ::SetEvent(start_event);
- ::CloseHandle(start_event);
- for (auto* thread : threads_) {
- ::WaitForSingleObject(thread, INFINITE);
- ::CloseHandle(thread);
- }
-
- return true;
-}
-
-bool InternalRunLocationTest() {
- // Create a new handle and then set LastError again.
- HANDLE handle = ::CreateMutex(nullptr, false, nullptr);
- if (!handle)
- return false;
- ScopedHandle handle_holder(handle);
-
- HMODULE verifier_module = GetHandleVerifierModuleForTesting();
- if (!verifier_module)
- return false;
-
- // Get my module
- HMODULE my_module = CURRENT_MODULE();
- if (!my_module)
- return false;
-
- HMODULE main_module = ::GetModuleHandle(NULL);
-
-#if BUILDFLAG(SINGLE_MODULE_MODE_HANDLE_VERIFIER)
- // In a component build ActiveVerifier will always be created inside base.dll
- // as the code always lives there.
- if (verifier_module == my_module || verifier_module == main_module)
- return false;
-#else
- // In a non-component build, ActiveVerifier should always be created in the
- // version of base linked with the main executable.
- if (verifier_module == my_module || verifier_module != main_module)
- return false;
-#endif
- return true;
-}
-
-} // namespace
-
-bool RunTest() {
- return InternalRunThreadTest() && InternalRunLocationTest();
-}
-
-} // testing
-} // win
-} // base
diff --git a/base/win/scoped_hdc.h b/base/win/scoped_hdc.h
deleted file mode 100644
index 890e34a82c..0000000000
--- a/base/win/scoped_hdc.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_WIN_SCOPED_HDC_H_
-#define BASE_WIN_SCOPED_HDC_H_
-
-#include <windows.h>
-
-#include "base/debug/gdi_debug_util_win.h"
-#include "base/logging.h"
-#include "base/macros.h"
-#include "base/win/scoped_handle.h"
-
-namespace base {
-namespace win {
-
-// Like ScopedHandle but for HDC. Only use this on HDCs returned from
-// GetDC.
-class ScopedGetDC {
- public:
- explicit ScopedGetDC(HWND hwnd)
- : hwnd_(hwnd),
- hdc_(GetDC(hwnd)) {
- if (hwnd_) {
- DCHECK(IsWindow(hwnd_));
- DCHECK(hdc_);
- } else {
- // If GetDC(NULL) returns NULL, something really bad has happened, like
- // GDI handle exhaustion. In this case Chrome is going to behave badly no
- // matter what, so we may as well just force a crash now.
- if (!hdc_)
- base::debug::CollectGDIUsageAndDie();
- }
- }
-
- ~ScopedGetDC() {
- if (hdc_)
- ReleaseDC(hwnd_, hdc_);
- }
-
- operator HDC() { return hdc_; }
-
- private:
- HWND hwnd_;
- HDC hdc_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedGetDC);
-};
-
-// Like ScopedHandle but for HDC. Only use this on HDCs returned from
-// CreateCompatibleDC, CreateDC and CreateIC.
-class CreateDCTraits {
- public:
- typedef HDC Handle;
-
- static bool CloseHandle(HDC handle) {
- return ::DeleteDC(handle) != FALSE;
- }
-
- static bool IsHandleValid(HDC handle) {
- return handle != NULL;
- }
-
- static HDC NullHandle() {
- return NULL;
- }
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(CreateDCTraits);
-};
-
-typedef GenericScopedHandle<CreateDCTraits, DummyVerifierTraits> ScopedCreateDC;
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_SCOPED_HDC_H_
diff --git a/base/win/scoped_hglobal.h b/base/win/scoped_hglobal.h
deleted file mode 100644
index abe9a5a3dd..0000000000
--- a/base/win/scoped_hglobal.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_WIN_SCOPED_HGLOBAL_H_
-#define BASE_WIN_SCOPED_HGLOBAL_H_
-
-#include <windows.h>
-#include <stddef.h>
-
-#include "base/macros.h"
-
-namespace base {
-namespace win {
-
-// Like ScopedHandle except for HGLOBAL.
-template<class T>
-class ScopedHGlobal {
- public:
- explicit ScopedHGlobal(HGLOBAL glob) : glob_(glob) {
- data_ = static_cast<T>(GlobalLock(glob_));
- }
- ~ScopedHGlobal() {
- GlobalUnlock(glob_);
- }
-
- T get() { return data_; }
-
- size_t Size() const { return GlobalSize(glob_); }
-
- T operator->() const {
- assert(data_ != 0);
- return data_;
- }
-
- T release() {
- T data = data_;
- data_ = NULL;
- return data;
- }
-
- private:
- HGLOBAL glob_;
-
- T data_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedHGlobal);
-};
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_SCOPED_HGLOBAL_H_
diff --git a/base/win/scoped_propvariant.h b/base/win/scoped_propvariant.h
deleted file mode 100644
index aa9afec1c1..0000000000
--- a/base/win/scoped_propvariant.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_WIN_SCOPED_PROPVARIANT_H_
-#define BASE_WIN_SCOPED_PROPVARIANT_H_
-
-#include <propidl.h>
-
-#include "base/logging.h"
-#include "base/macros.h"
-
-namespace base {
-namespace win {
-
-// A PROPVARIANT that is automatically initialized and cleared upon respective
-// construction and destruction of this class.
-class ScopedPropVariant {
- public:
- ScopedPropVariant() {
- PropVariantInit(&pv_);
- }
-
- ~ScopedPropVariant() {
- Reset();
- }
-
- // Returns a pointer to the underlying PROPVARIANT for use as an out param in
- // a function call.
- PROPVARIANT* Receive() {
- DCHECK_EQ(pv_.vt, VT_EMPTY);
- return &pv_;
- }
-
- // Clears the instance to prepare it for re-use (e.g., via Receive).
- void Reset() {
- if (pv_.vt != VT_EMPTY) {
- HRESULT result = PropVariantClear(&pv_);
- DCHECK_EQ(result, S_OK);
- }
- }
-
- const PROPVARIANT& get() const { return pv_; }
- const PROPVARIANT* ptr() const { return &pv_; }
-
- private:
- PROPVARIANT pv_;
-
- // Comparison operators for ScopedPropVariant are not supported at this point.
- bool operator==(const ScopedPropVariant&) const;
- bool operator!=(const ScopedPropVariant&) const;
- DISALLOW_COPY_AND_ASSIGN(ScopedPropVariant);
-};
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_SCOPED_PROPVARIANT_H_
diff --git a/base/win/scoped_select_object.h b/base/win/scoped_select_object.h
deleted file mode 100644
index 59b21c1335..0000000000
--- a/base/win/scoped_select_object.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_WIN_SCOPED_SELECT_OBJECT_H_
-#define BASE_WIN_SCOPED_SELECT_OBJECT_H_
-
-#include <windows.h>
-
-#include "base/logging.h"
-#include "base/macros.h"
-
-namespace base {
-namespace win {
-
-// Helper class for deselecting object from DC.
-class ScopedSelectObject {
- public:
- ScopedSelectObject(HDC hdc, HGDIOBJ object)
- : hdc_(hdc),
- oldobj_(SelectObject(hdc, object)) {
- DCHECK(hdc_);
- DCHECK(object);
- DCHECK(oldobj_ != NULL && oldobj_ != HGDI_ERROR);
- }
-
- ~ScopedSelectObject() {
- HGDIOBJ object = SelectObject(hdc_, oldobj_);
- DCHECK((GetObjectType(oldobj_) != OBJ_REGION && object != NULL) ||
- (GetObjectType(oldobj_) == OBJ_REGION && object != HGDI_ERROR));
- }
-
- private:
- HDC hdc_;
- HGDIOBJ oldobj_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedSelectObject);
-};
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_SCOPED_SELECT_OBJECT_H_
diff --git a/base/win/windows_version_unittest.cc b/base/win/windows_version_unittest.cc
deleted file mode 100644
index f0d6d9660d..0000000000
--- a/base/win/windows_version_unittest.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/win/windows_version.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace base {
-namespace win {
-namespace {
-
-TEST(WindowsVersion, GetVersionExAndKernelVersionMatch) {
- // If this fails, we're running in compatibility mode, or need to update the
- // application manifest.
- EXPECT_EQ(OSInfo::GetInstance()->version(),
- OSInfo::GetInstance()->Kernel32Version());
-}
-
-} // namespace
-} // namespace win
-} // namespace base