diff options
author | gbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-18 05:41:23 +0000 |
---|---|---|
committer | gbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-18 05:41:23 +0000 |
commit | 4f60d80fe11923a832b5d1dfca1373debde321db (patch) | |
tree | 63119dc1264958b19a46c980ea0112389fb49a77 | |
parent | 7e77b05ee015b7c8621cce2d5d3f711945f7d4c7 (diff) | |
download | chromium_src-4f60d80fe11923a832b5d1dfca1373debde321db.zip chromium_src-4f60d80fe11923a832b5d1dfca1373debde321db.tar.gz chromium_src-4f60d80fe11923a832b5d1dfca1373debde321db.tar.bz2 |
Regularize storage monitor creation in Windows.
BUG=None
Review URL: https://chromiumcodereview.appspot.com/12647013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194784 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/threading/sequenced_worker_pool.h | 8 | ||||
-rw-r--r-- | base/threading/sequenced_worker_pool_unittest.cc | 16 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main_win.cc | 11 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main_win.h | 3 | ||||
-rw-r--r-- | chrome/browser/storage_monitor/volume_mount_watcher_win.cc | 1 |
5 files changed, 29 insertions, 10 deletions
diff --git a/base/threading/sequenced_worker_pool.h b/base/threading/sequenced_worker_pool.h index a96cd76..7e04b07 100644 --- a/base/threading/sequenced_worker_pool.h +++ b/base/threading/sequenced_worker_pool.h @@ -57,10 +57,10 @@ class SequencedTaskRunner; // These will be executed in an unspecified order. The order of execution // between tasks with different sequence tokens is also unspecified. // -// This class is designed to be leaked on shutdown to allow the -// CONTINUE_ON_SHUTDOWN behavior to be implemented. To enforce the -// BLOCK_SHUTDOWN behavior, you must call Shutdown() which will wait until -// the necessary tasks have completed. +// This class may be leaked on shutdown to facilitate fast shutdown. The +// expected usage, however, is to call Shutdown(), which correctly accounts +// for CONTINUE_ON_SHUTDOWN behavior and is required for BLOCK_SHUTDOWN +// behavior. // // Implementation note: This does not use a base::WorkerPool since that does // not enforce shutdown semantics or allow us to specify how many worker diff --git a/base/threading/sequenced_worker_pool_unittest.cc b/base/threading/sequenced_worker_pool_unittest.cc index f0caf1a..95e4f11 100644 --- a/base/threading/sequenced_worker_pool_unittest.cc +++ b/base/threading/sequenced_worker_pool_unittest.cc @@ -28,7 +28,7 @@ namespace base { // IMPORTANT NOTE: // // Many of these tests have failure modes where they'll hang forever. These -// tests should not be flaky, and hangling indicates a type of failure. Do not +// tests should not be flaky, and hanging indicates a type of failure. Do not // mark as flaky if they're hanging, it's likely an actual bug. namespace { @@ -781,7 +781,7 @@ TEST_F(SequencedWorkerPoolTest, FlushForTesting) { true)); // We expect all except the delayed task to have been run. We verify all - // closures have been deleted deleted by looking at the refcount of the + // closures have been deleted by looking at the refcount of the // tracker. EXPECT_FALSE(tracker()->HasOneRef()); pool()->FlushForTesting(); @@ -798,6 +798,18 @@ TEST_F(SequencedWorkerPoolTest, FlushForTesting) { pool()->FlushForTesting(); } +TEST(SequencedWorkerPoolRefPtrTest, ShutsDownCleanWithContinueOnShutdown) { + MessageLoop loop; + scoped_refptr<SequencedWorkerPool> pool(new SequencedWorkerPool(3, "Pool")); + scoped_refptr<SequencedTaskRunner> task_runner = + pool->GetSequencedTaskRunnerWithShutdownBehavior( + pool->GetSequenceToken(), + base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); + + // Upon test exit, should shut down without hanging. + pool->Shutdown(); +} + class SequencedWorkerPoolTaskRunnerTestDelegate { public: SequencedWorkerPoolTaskRunnerTestDelegate() {} diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc index 083c59d..e8cd593 100644 --- a/chrome/browser/chrome_browser_main_win.cc +++ b/chrome/browser/chrome_browser_main_win.cc @@ -199,7 +199,6 @@ void ChromeBrowserMainPartsWin::PreMainMessageLoopStart() { // Make sure that we know how to handle exceptions from the message loop. InitializeWindowProcExceptions(); } - storage_monitor_.reset(chrome::StorageMonitorWin::Create()); } void ChromeBrowserMainPartsWin::PostMainMessageLoopStart() { @@ -217,10 +216,16 @@ void ChromeBrowserMainPartsWin::PostMainMessageLoopStart() { } } -void ChromeBrowserMainPartsWin::PreMainMessageLoopRun() { - ChromeBrowserMainParts::PreMainMessageLoopRun(); +void ChromeBrowserMainPartsWin::PreProfileInit() { + storage_monitor_.reset(chrome::StorageMonitorWin::Create()); + ChromeBrowserMainParts::PreProfileInit(); +} + +void ChromeBrowserMainPartsWin::PostProfileInit() { storage_monitor_->Init(); + + ChromeBrowserMainParts::PostProfileInit(); } void ChromeBrowserMainPartsWin::ShowMissingLocaleMessageBox() { diff --git a/chrome/browser/chrome_browser_main_win.h b/chrome/browser/chrome_browser_main_win.h index 5d7f371..78af86c 100644 --- a/chrome/browser/chrome_browser_main_win.h +++ b/chrome/browser/chrome_browser_main_win.h @@ -33,7 +33,8 @@ class ChromeBrowserMainPartsWin : public ChromeBrowserMainParts { virtual void ToolkitInitialized() OVERRIDE; virtual void PreMainMessageLoopStart() OVERRIDE; virtual void PostMainMessageLoopStart() OVERRIDE; - virtual void PreMainMessageLoopRun() OVERRIDE; + virtual void PreProfileInit() OVERRIDE; + virtual void PostProfileInit() OVERRIDE; // ChromeBrowserMainParts overrides. virtual void ShowMissingLocaleMessageBox() OVERRIDE; diff --git a/chrome/browser/storage_monitor/volume_mount_watcher_win.cc b/chrome/browser/storage_monitor/volume_mount_watcher_win.cc index 452a1eb..745b631 100644 --- a/chrome/browser/storage_monitor/volume_mount_watcher_win.cc +++ b/chrome/browser/storage_monitor/volume_mount_watcher_win.cc @@ -373,6 +373,7 @@ void VolumeMountWatcherWin::SetNotifications( VolumeMountWatcherWin::~VolumeMountWatcherWin() { weak_factory_.InvalidateWeakPtrs(); + device_info_worker_pool_->Shutdown(); } void VolumeMountWatcherWin::HandleDeviceAttachEventOnUIThread( |