diff options
-rw-r--r-- | base/base_lib.scons | 9 | ||||
-rw-r--r-- | base/base_unittests.scons | 12 | ||||
-rw-r--r-- | base/build/base.vcproj | 6 | ||||
-rw-r--r-- | base/build/base_unittests.vcproj | 4 | ||||
-rw-r--r-- | base/scoped_bstr_win.cc (renamed from base/scoped_bstr.cc) | 6 | ||||
-rw-r--r-- | base/scoped_bstr_win.h (renamed from base/scoped_bstr.h) | 10 | ||||
-rw-r--r-- | base/scoped_bstr_win_unittest.cc (renamed from base/scoped_bstr_unittest.cc) | 7 | ||||
-rw-r--r-- | base/scoped_comptr_win.h (renamed from base/scoped_comptr.h) | 39 | ||||
-rw-r--r-- | base/scoped_comptr_win_unittest.cc (renamed from base/scoped_comptr_unittest.cc) | 23 | ||||
-rw-r--r-- | base/time_win_unittest.cc (renamed from base/time_unittest_win.cc) | 0 |
10 files changed, 50 insertions, 66 deletions
diff --git a/base/base_lib.scons b/base/base_lib.scons index 65081dd..ee52dbf 100644 --- a/base/base_lib.scons +++ b/base/base_lib.scons @@ -179,11 +179,11 @@ input_files = ChromeFileList([ 'resource_util.h', 'revocable_store.cc', 'revocable_store.h', - 'scoped_bstr.cc', - 'scoped_bstr.h', + 'scoped_bstr_win.cc', + 'scoped_bstr_win.h', 'scoped_clipboard_writer.cc', 'scoped_clipboard_writer.h', - 'scoped_comptr.h', + 'scoped_comptr_win.h', 'scoped_handle.h', 'scoped_nsautorelease_pool.h', 'scoped_ptr.h', @@ -307,6 +307,9 @@ if not env.Bit('windows'): 'process_win.cc', 'rand_util_win.cc', 'registry.cc', + 'scoped_bstr_win.cc', + 'scoped_bstr_win.h', + 'scoped_comptr_win.h', 'shared_memory_win.cc', 'sys_info_win.cc', 'sys_string_conversions_win.cc', diff --git a/base/base_unittests.scons b/base/base_unittests.scons index 858874a..69172e9 100644 --- a/base/base_unittests.scons +++ b/base/base_unittests.scons @@ -85,8 +85,8 @@ input_files = ChromeFileList([ 'rand_util_unittest.cc', 'gfx/rect_unittest.cc', 'ref_counted_unittest.cc', - 'scoped_bstr_unittest.cc', - 'scoped_comptr_unittest.cc', + 'scoped_bstr_win_unittest.cc', + 'scoped_comptr_win_unittest.cc', 'scoped_ptr_unittest.cc', 'sha2_unittest.cc', 'shared_memory_unittest.cc', @@ -106,7 +106,7 @@ input_files = ChromeFileList([ 'thread_local_unittest.cc', 'thread_unittest.cc', 'time_unittest.cc', - 'time_unittest_win.cc', + 'time_win_unittest.cc', 'timer_unittest.cc', 'tracked_objects_unittest.cc', 'tuple_unittest.cc', @@ -155,11 +155,11 @@ if not env.Bit('windows'): 'file_version_info_unittest.cc', 'object_watcher_unittest.cc', 'pe_image_unittest.cc', - 'scoped_bstr_unittest.cc', - 'scoped_comptr_unittest.cc', + 'scoped_bstr_win_unittest.cc', + 'scoped_comptr_win_unittest.cc', 'system_monitor_unittest.cc', 'sys_string_conversions_unittest.cc', - 'time_unittest_win.cc', + 'time_win_unittest.cc', 'win_util_unittest.cc', 'wmi_util_unittest.cc', ) diff --git a/base/build/base.vcproj b/base/build/base.vcproj index b2933fd..c5de938 100644 --- a/base/build/base.vcproj +++ b/base/build/base.vcproj @@ -686,11 +686,11 @@ > </File> <File - RelativePath="..\scoped_bstr.cc" + RelativePath="..\scoped_bstr_win.cc" > </File> <File - RelativePath="..\scoped_bstr.h" + RelativePath="..\scoped_bstr_win.h" > </File> <File @@ -702,7 +702,7 @@ > </File> <File - RelativePath="..\scoped_comptr.h" + RelativePath="..\scoped_comptr_win.h" > </File> <File diff --git a/base/build/base_unittests.vcproj b/base/build/base_unittests.vcproj index 2642c22..b8a42e5 100644 --- a/base/build/base_unittests.vcproj +++ b/base/build/base_unittests.vcproj @@ -284,11 +284,11 @@ > </File> <File - RelativePath="..\scoped_bstr_unittest.cc" + RelativePath="..\scoped_bstr_win_unittest.cc" > </File> <File - RelativePath="..\scoped_comptr_unittest.cc" + RelativePath="..\scoped_comptr_win_unittest.cc" > </File> <File diff --git a/base/scoped_bstr.cc b/base/scoped_bstr_win.cc index 908e24e..0e4efca 100644 --- a/base/scoped_bstr.cc +++ b/base/scoped_bstr_win.cc @@ -2,13 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/scoped_bstr.h" +#include "base/scoped_bstr_win.h" #include "base/logging.h" -#if defined(OS_WIN) - ScopedBstr::ScopedBstr(const wchar_t* non_bstr) : bstr_(SysAllocString(non_bstr)) { } @@ -66,5 +64,3 @@ uint32 ScopedBstr::Length() const { uint32 ScopedBstr::ByteLength() const { return SysStringByteLen(bstr_); } - -#endif // defined(OS_WIN) diff --git a/base/scoped_bstr.h b/base/scoped_bstr_win.h index 00a0484..96979b5 100644 --- a/base/scoped_bstr.h +++ b/base/scoped_bstr_win.h @@ -2,13 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef BASE_SCOPED_BSTR_H_ -#define BASE_SCOPED_BSTR_H_ +#ifndef BASE_SCOPED_BSTR_WIN_H_ +#define BASE_SCOPED_BSTR_WIN_H_ #include "base/basictypes.h" // needed to pick up OS_WIN - -#if defined(OS_WIN) #include "base/logging.h" #include <windows.h> @@ -142,6 +140,4 @@ class StackBstrT { #define StackBstrVar(str, var) \ StackBstrT<sizeof(str)> var(str) -#endif // #if defined(OS_WIN) - -#endif // BASE_SCOPED_BSTR_H_ +#endif // BASE_SCOPED_BSTR_WIN_H_ diff --git a/base/scoped_bstr_unittest.cc b/base/scoped_bstr_win_unittest.cc index ed3ab22..a2e49ac 100644 --- a/base/scoped_bstr_unittest.cc +++ b/base/scoped_bstr_win_unittest.cc @@ -2,12 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/scoped_bstr.h" +#include "base/scoped_bstr_win.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_WIN) -#include <oleauto.h> // VarBstrCmp - namespace { static const wchar_t kTestString1[] = L"123"; @@ -94,5 +91,3 @@ TEST(StackBstrTest, StackBstr) { EXPECT_EQ(SysStringLen(StackBstr(one_more_test)), lstrlenW(one_more_test)); } - -#endif // defined(OS_WIN) diff --git a/base/scoped_comptr.h b/base/scoped_comptr_win.h index e8f1275..8f677a0 100644 --- a/base/scoped_comptr.h +++ b/base/scoped_comptr_win.h @@ -2,17 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef BASE_SCOPED_COMPTR_H_ -#define BASE_SCOPED_COMPTR_H_ +#ifndef BASE_SCOPED_COMPTR_WIN_H_ +#define BASE_SCOPED_COMPTR_WIN_H_ + +#include <unknwn.h> #include "base/logging.h" #include "base/ref_counted.h" -#if defined(OS_WIN) -#include <unknwn.h> - -// Utility template to prevent users of scoped_comptr from calling AddRef and/or -// Release() without going through the scoped_comptr class. +// Utility template to prevent users of ScopedComPtr from calling AddRef and/or +// Release() without going through the ScopedComPtr class. template <class Interface>
class BlockIUnknownMethods : public Interface {
private:
@@ -25,29 +24,29 @@ class BlockIUnknownMethods : public Interface { // 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 scoped_comptr : public scoped_refptr<Interface> { +class ScopedComPtr : public scoped_refptr<Interface> { public: typedef scoped_refptr<Interface> ParentClass; - scoped_comptr() { + ScopedComPtr() { } - explicit scoped_comptr(Interface* p) : ParentClass(p) { + explicit ScopedComPtr(Interface* p) : ParentClass(p) { } - explicit scoped_comptr(const scoped_comptr<Interface, interface_id>& p) + explicit ScopedComPtr(const ScopedComPtr<Interface, interface_id>& p) : ParentClass(p) { } - ~scoped_comptr() { + ~ScopedComPtr() { // We don't want the smart pointer class to be bigger than the pointer // it wraps. - COMPILE_ASSERT(sizeof(scoped_comptr<Interface, interface_id>) == + COMPILE_ASSERT(sizeof(ScopedComPtr<Interface, interface_id>) == sizeof(Interface*), ScopedComPtrSize); } // Explicit Release() of the held object. Useful for reuse of the - // scoped_comptr instance. + // ScopedComPtr instance. // Note that this function equates to IUnknown::Release and should not // be confused with e.g. scoped_ptr::release(). void Release() { @@ -114,10 +113,10 @@ class scoped_comptr : public scoped_refptr<Interface> { if (!other || !ptr_)
return false;
- scoped_comptr<IUnknown> my_identity;
+ ScopedComPtr<IUnknown> my_identity;
QueryInterface(my_identity.Receive());
- scoped_comptr<IUnknown> other_identity;
+ ScopedComPtr<IUnknown> other_identity;
other->QueryInterface(other_identity.Receive());
return static_cast<IUnknown*>(my_identity) ==
@@ -127,12 +126,12 @@ class scoped_comptr : public scoped_refptr<Interface> { // Provides direct access to the interface. // Here we use a well known trick to make sure we block access to // IUknown methods so that something bad like this doesn't happen: - // scoped_comptr<IUnknown> p(Foo()); + // 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 scoped_comptr instance to the wrapped interface + // by statically casting the ScopedComPtr instance to the wrapped interface // and then making the call... but generally that shouldn't be necessary. BlockIUnknownMethods<Interface>* operator->() const { DCHECK(ptr_ != NULL); @@ -146,6 +145,4 @@ class scoped_comptr : public scoped_refptr<Interface> { } }; -#endif // #if defined(OS_WIN) - -#endif // BASE_SCOPED_COMPTR_H_ +#endif // BASE_SCOPED_COMPTR_WIN_H_ diff --git a/base/scoped_comptr_unittest.cc b/base/scoped_comptr_win_unittest.cc index 2eee91e..96ebcc6 100644 --- a/base/scoped_comptr_unittest.cc +++ b/base/scoped_comptr_win_unittest.cc @@ -2,31 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/scoped_comptr.h" -#include "testing/gtest/include/gtest/gtest.h" - -#if defined(OS_WIN) #include <shlobj.h> +#include "base/scoped_comptr_win.h" +#include "testing/gtest/include/gtest/gtest.h" + TEST(ScopedComPtrTest, ScopedComPtr) { - EXPECT_TRUE(memcmp(&scoped_comptr<IUnknown>::iid(), &IID_IUnknown, + EXPECT_TRUE(memcmp(&ScopedComPtr<IUnknown>::iid(), &IID_IUnknown, sizeof(IID)) == 0); EXPECT_TRUE(SUCCEEDED(::CoInitialize(NULL))); { - scoped_comptr<IUnknown> unk; + ScopedComPtr<IUnknown> unk; EXPECT_TRUE(SUCCEEDED(unk.CreateInstance(CLSID_ShellLink))); - scoped_comptr<IUnknown> unk2; + ScopedComPtr<IUnknown> unk2; unk2.Attach(unk.Detach()); EXPECT_TRUE(unk == NULL); EXPECT_TRUE(unk2 != NULL); - scoped_comptr<IMalloc> mem_alloc; + ScopedComPtr<IMalloc> mem_alloc; EXPECT_TRUE(SUCCEEDED(CoGetMalloc(1, mem_alloc.Receive()))); - // test scoped_comptr& constructor - scoped_comptr<IMalloc> copy1(mem_alloc); + // test ScopedComPtr& constructor + ScopedComPtr<IMalloc> copy1(mem_alloc); EXPECT_TRUE(copy1.IsSameObject(mem_alloc)); EXPECT_FALSE(copy1.IsSameObject(unk2)); // unk2 is valid but different EXPECT_FALSE(copy1.IsSameObject(unk)); // unk is NULL @@ -34,7 +33,7 @@ TEST(ScopedComPtrTest, ScopedComPtr) { EXPECT_FALSE(copy1.IsSameObject(unk2)); // unk2 is valid, copy1 is not // test Interface* constructor - scoped_comptr<IMalloc> copy2(static_cast<IMalloc*>(mem_alloc)); + ScopedComPtr<IMalloc> copy2(static_cast<IMalloc*>(mem_alloc)); EXPECT_TRUE(copy2.IsSameObject(mem_alloc)); EXPECT_TRUE(SUCCEEDED(unk.QueryFrom(mem_alloc))); @@ -46,5 +45,3 @@ TEST(ScopedComPtrTest, ScopedComPtr) { ::CoUninitialize(); } - -#endif // defined(OS_WIN)
\ No newline at end of file diff --git a/base/time_unittest_win.cc b/base/time_win_unittest.cc index 4b63f6b..4b63f6b 100644 --- a/base/time_unittest_win.cc +++ b/base/time_win_unittest.cc |