diff options
-rw-r--r-- | chrome/browser/importer/ie_importer.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/accessibility/accessibility_event_router_views_unittest.cc | 14 | ||||
-rw-r--r-- | chrome/test/base/chrome_test_suite.h | 8 | ||||
-rw-r--r-- | chrome_frame/test/net/fake_external_tab.cc | 10 | ||||
-rw-r--r-- | chrome_frame/test/net/fake_external_tab.h | 2 | ||||
-rw-r--r-- | chrome_frame/test/run_all_unittests.cc | 20 | ||||
-rw-r--r-- | chrome_frame/test/url_request_test.cc | 5 | ||||
-rw-r--r-- | content/browser/accessibility/browser_accessibility_win_unittest.cc | 3 | ||||
-rw-r--r-- | content/browser/geolocation/win7_location_api_win.h | 4 | ||||
-rw-r--r-- | content/browser/renderer_host/render_process_host_impl.cc | 16 | ||||
-rw-r--r-- | content/public/test/test_renderer_host.cc | 30 | ||||
-rw-r--r-- | content/public/test/test_renderer_host.h | 7 | ||||
-rw-r--r-- | content/test/content_test_launcher.cc | 5 | ||||
-rw-r--r-- | ui/aura/test/aura_test_helper.h | 8 |
14 files changed, 67 insertions, 69 deletions
diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index 7bef316..55bb95d 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -24,7 +24,6 @@ #include "base/utf_string_conversions.h" #include "base/win/registry.h" #include "base/win/scoped_co_mem.h" -#include "base/win/scoped_com_initializer.h" #include "base/win/scoped_comptr.h" #include "base/win/scoped_handle.h" #include "base/win/windows_version.h" @@ -415,9 +414,6 @@ void IEImporter::StartImport(const importer::SourceProfile& source_profile, bridge_->NotifyStarted(); - // Some IE settings (such as Protected Storage) are obtained via COM APIs. - base::win::ScopedCOMInitializer com_initializer; - if ((items & importer::HOME_PAGE) && !cancelled()) ImportHomepage(); // Doesn't have a UI item. // The order here is important! diff --git a/chrome/browser/ui/views/accessibility/accessibility_event_router_views_unittest.cc b/chrome/browser/ui/views/accessibility/accessibility_event_router_views_unittest.cc index 53caf11..4aa9ae7 100644 --- a/chrome/browser/ui/views/accessibility/accessibility_event_router_views_unittest.cc +++ b/chrome/browser/ui/views/accessibility/accessibility_event_router_views_unittest.cc @@ -24,6 +24,10 @@ #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" +#if defined(OS_WIN) +#include "ui/base/win/scoped_ole_initializer.h" +#endif + #if defined(USE_AURA) #include "ui/aura/test/aura_test_helper.h" #endif @@ -89,6 +93,9 @@ class AccessibilityEventRouterViewsTest } virtual void SetUp() { +#if defined(OS_WIN) + ole_initializer_.reset(new ui::ScopedOleInitializer()); +#endif views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); #if defined(USE_AURA) aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); @@ -107,6 +114,10 @@ class AccessibilityEventRouterViewsTest // forces it to be deleted now, so we don't have any memory leaks // when this method exits. MessageLoop::current()->RunAllPending(); + +#if defined(OS_WIN) + ole_initializer_.reset(); +#endif } views::Widget* CreateWindowWithContents(views::View* contents) { @@ -133,6 +144,9 @@ class AccessibilityEventRouterViewsTest int focus_event_count_; std::string last_control_name_; std::string last_control_context_; +#if defined(OS_WIN) + scoped_ptr<ui::ScopedOleInitializer> ole_initializer_; +#endif #if defined(USE_AURA) scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; #endif diff --git a/chrome/test/base/chrome_test_suite.h b/chrome/test/base/chrome_test_suite.h index 756b22e..2978f89 100644 --- a/chrome/test/base/chrome_test_suite.h +++ b/chrome/test/base/chrome_test_suite.h @@ -11,10 +11,6 @@ #include "base/memory/scoped_ptr.h" #include "content/public/test/content_test_suite_base.h" -#if defined(OS_WIN) -#include "ui/base/win/scoped_ole_initializer.h" -#endif - namespace base { class StatsTable; } @@ -39,10 +35,6 @@ class ChromeTestSuite : public content::ContentTestSuiteBase { std::string stats_filename_; scoped_ptr<base::StatsTable> stats_table_; - -#if defined(OS_WIN) - ui::ScopedOleInitializer ole_initializer_; -#endif }; #endif // CHROME_TEST_BASE_CHROME_TEST_SUITE_H_ diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc index 943bdcde..470b296 100644 --- a/chrome_frame/test/net/fake_external_tab.cc +++ b/chrome_frame/test/net/fake_external_tab.cc @@ -26,7 +26,6 @@ #include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" #include "base/threading/thread.h" -#include "base/win/scoped_com_initializer.h" #include "base/win/scoped_comptr.h" #include "base/win/scoped_handle.h" #include "chrome/app/chrome_main_delegate.h" @@ -534,7 +533,6 @@ void CFUrlRequestUnittestRunner::StartChromeFrameInHostBrowser() { if (!launch_browser_) return; - base::win::ScopedCOMInitializer com; chrome_frame_test::CloseAllIEWindows(); // Tweak IE settings to make it amenable to testing before launching it. @@ -563,10 +561,8 @@ void CFUrlRequestUnittestRunner::StartChromeFrameInHostBrowser() { } void CFUrlRequestUnittestRunner::ShutDownHostBrowser() { - if (launch_browser_) { - base::win::ScopedCOMInitializer com; + if (launch_browser_) chrome_frame_test::CloseAllIEWindows(); - } } void CFUrlRequestUnittestRunner::OnIEShutdownFailure() { @@ -725,10 +721,8 @@ void CFUrlRequestUnittestRunner::OnInitializationTimeout() { StopFileLogger(true); - if (launch_browser_) { - base::win::ScopedCOMInitializer com; + if (launch_browser_) chrome_frame_test::CloseAllIEWindows(); - } if (ie_configurator_.get() != NULL) ie_configurator_->RevertSettings(); diff --git a/chrome_frame/test/net/fake_external_tab.h b/chrome_frame/test/net/fake_external_tab.h index e4c2749..18e24b0 100644 --- a/chrome_frame/test/net/fake_external_tab.h +++ b/chrome_frame/test/net/fake_external_tab.h @@ -52,7 +52,7 @@ class FakeExternalTab { FakeBrowserProcessImpl* browser_process() const; - protected: + private: scoped_ptr<FakeBrowserProcessImpl> browser_process_; FilePath overridden_user_dir_; FilePath user_data_dir_; diff --git a/chrome_frame/test/run_all_unittests.cc b/chrome_frame/test/run_all_unittests.cc index b0f502e..55e21cc 100644 --- a/chrome_frame/test/run_all_unittests.cc +++ b/chrome_frame/test/run_all_unittests.cc @@ -25,14 +25,13 @@ class ChromeFrameUnittestsModule : public CAtlExeModuleT<ChromeFrameUnittestsModule> { public: - static HRESULT InitializeCom() { - // Note that this only gets called in versions of ATL included in - // VS2008 and earlier. We still need it however since this gets called - // at static initialization time, before the ScopedCOMInitializer in main() - // and the default implementation of InitializeCom CoInitializes into the - // MTA. - return CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); - } + // Called at static init time, for versions of ATL included in VS2008 and + // earlier only. The default implementation initializes COM in MTA mode, + // which we don't want. We could init STA mode here, but since we have to + // init in main() for VS2010 and above anyway, we simply do nothing, since + // nothing needs COM before main() runs. + static HRESULT InitializeCom() { return S_OK; } + static void UninitializeCom() {} }; ChromeFrameUnittestsModule _AtlModule; @@ -46,7 +45,10 @@ void PureCall() { } int main(int argc, char **argv) { - base::win::ScopedCOMInitializer com_initializer; + // For ATL in VS2010 and up, ChromeFrameUnittestsModule::InitializeCom() is + // not called, so we init COM here. + base::win::ScopedCOMInitializer com_initializer_; + ScopedChromeFrameRegistrar::RegisterAndExitProcessIfDirected(); base::EnableTerminationOnHeapCorruption(); base::PlatformThread::SetName("ChromeFrame tests"); diff --git a/chrome_frame/test/url_request_test.cc b/chrome_frame/test/url_request_test.cc index 6c1790f..8da74bc 100644 --- a/chrome_frame/test/url_request_test.cc +++ b/chrome_frame/test/url_request_test.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/win/scoped_com_initializer.h" #include "chrome/common/automation_messages.h" #include "chrome_frame/test/chrome_frame_test_utils.h" #include "chrome_frame/test/test_server.h" @@ -72,7 +71,6 @@ TEST(UrlmonUrlRequestTest, Simple1) { chrome_frame_test::GetTestDataFolder()); mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); - base::win::ScopedCOMInitializer init_com; CComObjectStackEx<UrlmonUrlRequest> request; request.AddRef(); @@ -121,7 +119,6 @@ TEST(UrlmonUrlRequestTest, Head) { test_server::SimpleResponse head_response("/head", ""); server.AddResponse(&head_response); - base::win::ScopedCOMInitializer init_com; CComObjectStackEx<UrlmonUrlRequest> request; request.AddRef(); @@ -158,7 +155,6 @@ TEST(UrlmonUrlRequestTest, Head) { TEST(UrlmonUrlRequestTest, UnreachableUrl) { MockUrlDelegate mock; chrome_frame_test::TimedMsgLoop loop; - base::win::ScopedCOMInitializer init_com; CComObjectStackEx<UrlmonUrlRequest> request; testing::StrictMock<MockWebServer> mock_server(1337, @@ -206,7 +202,6 @@ TEST(UrlmonUrlRequestTest, ZeroLengthResponse) { chrome_frame_test::GetTestDataFolder()); mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); - base::win::ScopedCOMInitializer init_com; CComObjectStackEx<UrlmonUrlRequest> request; request.AddRef(); diff --git a/content/browser/accessibility/browser_accessibility_win_unittest.cc b/content/browser/accessibility/browser_accessibility_win_unittest.cc index bca0f99..8f67a3d 100644 --- a/content/browser/accessibility/browser_accessibility_win_unittest.cc +++ b/content/browser/accessibility/browser_accessibility_win_unittest.cc @@ -3,7 +3,6 @@ // found in the LICENSE file. #include "base/memory/scoped_ptr.h" -#include "base/win/scoped_com_initializer.h" #include "base/win/scoped_comptr.h" #include "content/browser/accessibility/browser_accessibility_manager.h" #include "content/browser/accessibility/browser_accessibility_win.h" @@ -60,8 +59,6 @@ class BrowserAccessibilityTest : public testing::Test { ui::win::CreateATLModuleIfNeeded(); } - base::win::ScopedCOMInitializer com_initializer_; - DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityTest); }; diff --git a/content/browser/geolocation/win7_location_api_win.h b/content/browser/geolocation/win7_location_api_win.h index 551cc5a..fc9ffc2 100644 --- a/content/browser/geolocation/win7_location_api_win.h +++ b/content/browser/geolocation/win7_location_api_win.h @@ -11,7 +11,7 @@ #include <locationapi.h> #include <sensors.h> -#include "base/win/scoped_com_initializer.h" +#include "base/basictypes.h" #include "content/common/content_export.h" namespace content { @@ -51,8 +51,6 @@ class CONTENT_EXPORT Win7LocationApi { // location information. virtual bool GetPositionIfFixed(content::Geoposition* position); - // Ensure that COM has been initialized for this thread. - base::win::ScopedCOMInitializer com_initializer_; // ILocation object that lets us communicate with the Location and // Sensors platform. CComPtr<ILocation> locator_; diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 5a019ed..ecdd9ba 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -136,7 +136,7 @@ namespace content { class RendererMainThread : public base::Thread { public: explicit RendererMainThread(const std::string& channel_id) - : base::Thread("Chrome_InProcRendererThread"), + : Thread("Chrome_InProcRendererThread"), channel_id_(channel_id) { } @@ -145,11 +145,7 @@ class RendererMainThread : public base::Thread { } protected: - virtual void Init() { -#if defined(OS_WIN) - com_initializer_.reset(new base::win::ScopedCOMInitializer()); -#endif - + virtual void Init() OVERRIDE { render_process_.reset(new RenderProcessImpl()); new RenderThreadImpl(channel_id_); } @@ -157,9 +153,6 @@ class RendererMainThread : public base::Thread { virtual void CleanUp() { render_process_.reset(); -#if defined(OS_WIN) - com_initializer_.reset(); -#endif // It's a little lame to manually set this flag. But the single process // RendererThread will receive the WM_QUIT. We don't need to assert on // this thread, so just force the flag manually. @@ -169,14 +162,11 @@ class RendererMainThread : public base::Thread { // other threads like WebThread which are created by this thread // which resets this flag. Please see Thread::StartWithOptions. Setting // this flag to true in Cleanup works around these problems. - base::Thread::SetThreadWasQuitProperly(true); + SetThreadWasQuitProperly(true); } private: std::string channel_id_; -#if defined(OS_WIN) - scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_; -#endif scoped_ptr<RenderProcess> render_process_; DISALLOW_COPY_AND_ASSIGN(RendererMainThread); diff --git a/content/public/test/test_renderer_host.cc b/content/public/test/test_renderer_host.cc index 67a00f3..be4328e 100644 --- a/content/public/test/test_renderer_host.cc +++ b/content/public/test/test_renderer_host.cc @@ -15,12 +15,18 @@ #include "content/public/test/test_browser_context.h" #include "content/test/test_render_view_host_factory.h" +#if defined(OS_WIN) +#include "ui/base/win/scoped_ole_initializer.h" +#endif + #if defined(USE_AURA) #include "ui/aura/test/aura_test_helper.h" #endif namespace content { +// RenderViewHostTester ------------------------------------------------------- + // static RenderViewHostTester* RenderViewHostTester::For(RenderViewHost* host) { return static_cast<TestRenderViewHost*>(host); @@ -51,6 +57,9 @@ bool RenderViewHostTester::HasTouchEventHandler(RenderViewHost* rvh) { return host_impl->has_touch_handler(); } + +// RenderViewHostTestEnabler -------------------------------------------------- + RenderViewHostTestEnabler::RenderViewHostTestEnabler() : rph_factory_(new MockRenderProcessHostFactory()), rvh_factory_(new TestRenderViewHostFactory(rph_factory_.get())) { @@ -59,8 +68,10 @@ RenderViewHostTestEnabler::RenderViewHostTestEnabler() RenderViewHostTestEnabler::~RenderViewHostTestEnabler() { } -RenderViewHostTestHarness::RenderViewHostTestHarness() - : contents_(NULL) { + +// RenderViewHostTestHarness -------------------------------------------------- + +RenderViewHostTestHarness::RenderViewHostTestHarness() : contents_(NULL) { } RenderViewHostTestHarness::~RenderViewHostTestHarness() { @@ -104,6 +115,14 @@ void RenderViewHostTestHarness::SetContents(WebContents* contents) { } WebContents* RenderViewHostTestHarness::CreateTestWebContents() { + // Make sure we ran SetUp() already. +#if defined(OS_WIN) + DCHECK(ole_initializer_ != NULL); +#endif +#if defined(USE_AURA) + DCHECK(aura_test_helper_ != NULL); +#endif + // See comment above browser_context_ decl for why we check for NULL here. if (!browser_context_.get()) browser_context_.reset(new content::TestBrowserContext()); @@ -127,6 +146,9 @@ void RenderViewHostTestHarness::Reload() { } void RenderViewHostTestHarness::SetUp() { +#if defined(OS_WIN) + ole_initializer_.reset(new ui::ScopedOleInitializer()); +#endif #if defined(USE_AURA) aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); aura_test_helper_->SetUp(); @@ -150,6 +172,10 @@ void RenderViewHostTestHarness::TearDown() { // Release the browser context on the UI thread. message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); message_loop_.RunAllPending(); + +#if defined(OS_WIN) + ole_initializer_.reset(); +#endif } void RenderViewHostTestHarness::SetRenderProcessHostFactory( diff --git a/content/public/test/test_renderer_host.h b/content/public/test/test_renderer_host.h index a580cf6..e53ef53 100644 --- a/content/public/test/test_renderer_host.h +++ b/content/public/test/test_renderer_host.h @@ -21,6 +21,10 @@ class AuraTestHelper; } } +namespace ui { +class ScopedOleInitializer; +} + namespace content { class BrowserContext; @@ -171,6 +175,9 @@ class RenderViewHostTestHarness : public testing::Test { // web_contents() and SetContents() are virtual and may be // overridden by subclasses. scoped_ptr<WebContents> contents_; +#if defined(OS_WIN) + scoped_ptr<ui::ScopedOleInitializer> ole_initializer_; +#endif #if defined(USE_AURA) scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; #endif diff --git a/content/test/content_test_launcher.cc b/content/test/content_test_launcher.cc index 82798be..1f2bece 100644 --- a/content/test/content_test_launcher.cc +++ b/content/test/content_test_launcher.cc @@ -21,7 +21,6 @@ #if defined(OS_WIN) #include "content/public/app/startup_helper_win.h" #include "sandbox/win/src/sandbox_types.h" -#include "ui/base/win/scoped_ole_initializer.h" #endif // defined(OS_WIN) namespace content { @@ -78,10 +77,6 @@ class ContentBrowserTestSuite : public ContentTestSuiteBase { return new ShellContentClient(); } -#if defined(OS_WIN) - ui::ScopedOleInitializer ole_initializer_; -#endif - DISALLOW_COPY_AND_ASSIGN(ContentBrowserTestSuite); }; diff --git a/ui/aura/test/aura_test_helper.h b/ui/aura/test/aura_test_helper.h index 2345f5c..d064a84 100644 --- a/ui/aura/test/aura_test_helper.h +++ b/ui/aura/test/aura_test_helper.h @@ -8,10 +8,6 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" -#if defined(OS_WIN) -#include "ui/base/win/scoped_ole_initializer.h" -#endif - class MessageLoopForUI; namespace ui { @@ -62,10 +58,6 @@ class AuraTestHelper { scoped_ptr<FocusManager> focus_manager_; scoped_ptr<aura::TestScreen> test_screen_; -#if defined(OS_WIN) - ui::ScopedOleInitializer ole_initializer_; -#endif - DISALLOW_COPY_AND_ASSIGN(AuraTestHelper); }; |