summaryrefslogtreecommitdiffstats
path: root/components/storage_monitor
diff options
context:
space:
mode:
authortommycli <tommycli@chromium.org>2015-03-03 12:41:01 -0800
committerCommit bot <commit-bot@chromium.org>2015-03-03 20:41:40 +0000
commit385e394071526ea23c76b12bf9b901315f562c97 (patch)
tree61186a1baced85cf0a832f566fc583e48cb2d7ea /components/storage_monitor
parent3611ddb22c7ae6d15816ecc9f2b4326c9f51d511 (diff)
downloadchromium_src-385e394071526ea23c76b12bf9b901315f562c97.zip
chromium_src-385e394071526ea23c76b12bf9b901315f562c97.tar.gz
chromium_src-385e394071526ea23c76b12bf9b901315f562c97.tar.bz2
Hotlist Slow: Remove extra thread pool created by VolumeMountWatcherWin.
BUG=458541 Review URL: https://codereview.chromium.org/974633002 Cr-Commit-Position: refs/heads/master@{#318936}
Diffstat (limited to 'components/storage_monitor')
-rw-r--r--components/storage_monitor/storage_monitor_win_unittest.cc1
-rw-r--r--components/storage_monitor/test_volume_mount_watcher_win.cc7
-rw-r--r--components/storage_monitor/test_volume_mount_watcher_win.h4
-rw-r--r--components/storage_monitor/volume_mount_watcher_win.cc29
-rw-r--r--components/storage_monitor/volume_mount_watcher_win.h8
5 files changed, 16 insertions, 33 deletions
diff --git a/components/storage_monitor/storage_monitor_win_unittest.cc b/components/storage_monitor/storage_monitor_win_unittest.cc
index 59aefcb..fd7ee58 100644
--- a/components/storage_monitor/storage_monitor_win_unittest.cc
+++ b/components/storage_monitor/storage_monitor_win_unittest.cc
@@ -97,7 +97,6 @@ void StorageMonitorWinTest::SetUp() {
void StorageMonitorWinTest::TearDown() {
RunUntilIdle();
monitor_->RemoveObserver(&observer_);
- volume_mount_watcher_->ShutdownWorkerPool();
// Windows storage monitor must be destroyed on the same thread
// as construction.
diff --git a/components/storage_monitor/test_volume_mount_watcher_win.cc b/components/storage_monitor/test_volume_mount_watcher_win.cc
index 77ea57b..234b87f 100644
--- a/components/storage_monitor/test_volume_mount_watcher_win.cc
+++ b/components/storage_monitor/test_volume_mount_watcher_win.cc
@@ -11,6 +11,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/strings/utf_string_conversions.h"
#include "components/storage_monitor/storage_info.h"
+#include "content/public/browser/browser_thread.h"
namespace storage_monitor {
@@ -108,7 +109,7 @@ void TestVolumeMountWatcherWin::SetAttachedDevicesFake() {
}
void TestVolumeMountWatcherWin::FlushWorkerPoolForTesting() {
- device_info_worker_pool_->FlushForTesting();
+ content::BrowserThread::GetBlockingPool()->FlushForTesting();
}
void TestVolumeMountWatcherWin::DeviceCheckComplete(
@@ -150,8 +151,4 @@ VolumeMountWatcherWin::GetAttachedDevicesCallbackType
return base::Bind(&FakeGetSingleAttachedDevice);
}
-void TestVolumeMountWatcherWin::ShutdownWorkerPool() {
- device_info_worker_pool_->Shutdown();
-}
-
} // namespace storage_monitor
diff --git a/components/storage_monitor/test_volume_mount_watcher_win.h b/components/storage_monitor/test_volume_mount_watcher_win.h
index 267d096..5191997 100644
--- a/components/storage_monitor/test_volume_mount_watcher_win.h
+++ b/components/storage_monitor/test_volume_mount_watcher_win.h
@@ -53,10 +53,6 @@ class TestVolumeMountWatcherWin : public VolumeMountWatcherWin {
virtual GetDeviceDetailsCallbackType
GetDeviceDetailsCallback() const override;
- // Should be used by unit tests to make sure the worker pool doesn't survive
- // into other test runs.
- void ShutdownWorkerPool();
-
private:
std::vector<base::FilePath> devices_checked_;
scoped_ptr<base::WaitableEvent> device_check_complete_event_;
diff --git a/components/storage_monitor/volume_mount_watcher_win.cc b/components/storage_monitor/volume_mount_watcher_win.cc
index fd3e6a5..6a89e1a 100644
--- a/components/storage_monitor/volume_mount_watcher_win.cc
+++ b/components/storage_monitor/volume_mount_watcher_win.cc
@@ -34,6 +34,8 @@ namespace {
const DWORD kMaxPathBufLen = MAX_PATH + 1;
+const char kDeviceInfoTaskRunnerName[] = "device-info-task-runner";
+
enum DeviceType {
FLOPPY,
REMOVABLE,
@@ -324,18 +326,12 @@ void EjectDeviceInThreadPool(
} // namespace
-const int kWorkerPoolNumThreads = 3;
-const char* kWorkerPoolNamePrefix = "DeviceInfoPool";
-
VolumeMountWatcherWin::VolumeMountWatcherWin()
- : device_info_worker_pool_(new base::SequencedWorkerPool(
- kWorkerPoolNumThreads, kWorkerPoolNamePrefix)),
- notifications_(NULL),
- weak_factory_(this) {
- task_runner_ =
- device_info_worker_pool_->GetSequencedTaskRunnerWithShutdownBehavior(
- device_info_worker_pool_->GetSequenceToken(),
- base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
+ : notifications_(NULL), weak_factory_(this) {
+ base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool();
+ device_info_task_runner_ = pool->GetSequencedTaskRunnerWithShutdownBehavior(
+ pool->GetNamedSequenceToken(kDeviceInfoTaskRunnerName),
+ base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
}
// static
@@ -361,7 +357,7 @@ void VolumeMountWatcherWin::Init() {
// so a posted task from the constructor would never run. Therefore, do all
// the initializations here.
base::PostTaskAndReplyWithResult(
- task_runner_.get(), FROM_HERE, GetAttachedDevicesCallback(),
+ device_info_task_runner_.get(), FROM_HERE, GetAttachedDevicesCallback(),
base::Bind(&VolumeMountWatcherWin::AddDevicesOnUIThread,
weak_factory_.GetWeakPtr()));
}
@@ -374,7 +370,7 @@ void VolumeMountWatcherWin::AddDevicesOnUIThread(
if (ContainsKey(pending_device_checks_, removable_devices[i]))
continue;
pending_device_checks_.insert(removable_devices[i]);
- task_runner_->PostTask(
+ device_info_task_runner_->PostTask(
FROM_HERE,
base::Bind(&VolumeMountWatcherWin::RetrieveInfoForDeviceAndAdd,
removable_devices[i], GetDeviceDetailsCallback(),
@@ -503,7 +499,6 @@ void VolumeMountWatcherWin::SetNotifications(
VolumeMountWatcherWin::~VolumeMountWatcherWin() {
weak_factory_.InvalidateWeakPtrs();
- device_info_worker_pool_->Shutdown();
}
void VolumeMountWatcherWin::HandleDeviceAttachEventOnUIThread(
@@ -548,9 +543,9 @@ void VolumeMountWatcherWin::EjectDevice(
return;
}
- task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&EjectDeviceInThreadPool, device, callback, task_runner_, 0));
+ device_info_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&EjectDeviceInThreadPool, device, callback,
+ device_info_task_runner_, 0));
}
} // namespace storage_monitor
diff --git a/components/storage_monitor/volume_mount_watcher_win.h b/components/storage_monitor/volume_mount_watcher_win.h
index 48f3741..bf351db 100644
--- a/components/storage_monitor/volume_mount_watcher_win.h
+++ b/components/storage_monitor/volume_mount_watcher_win.h
@@ -16,7 +16,6 @@
#include "base/memory/weak_ptr.h"
#include "base/sequenced_task_runner.h"
#include "base/strings/string16.h"
-#include "base/threading/sequenced_worker_pool.h"
#include "components/storage_monitor/storage_info.h"
#include "components/storage_monitor/storage_monitor.h"
@@ -90,11 +89,8 @@ class VolumeMountWatcherWin {
virtual GetAttachedDevicesCallbackType GetAttachedDevicesCallback() const;
virtual GetDeviceDetailsCallbackType GetDeviceDetailsCallback() const;
- // Worker pool used to collect device information. Used because some
- // devices freeze workers trying to get device info, resulting in
- // shutdown hangs.
- scoped_refptr<base::SequencedWorkerPool> device_info_worker_pool_;
- scoped_refptr<base::SequencedTaskRunner> task_runner_;
+ // Used for device info calls that may take a long time.
+ scoped_refptr<base::SequencedTaskRunner> device_info_task_runner_;
private:
friend class TestVolumeMountWatcherWin;