Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Unified Diff: components/storage_monitor/volume_mount_watcher_win.cc

Issue 974633002: Hotlist Slow: Remove extra thread pool created by VolumeMountWatcherWin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/storage_monitor/volume_mount_watcher_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/storage_monitor/volume_mount_watcher_win.cc
diff --git a/components/storage_monitor/volume_mount_watcher_win.cc b/components/storage_monitor/volume_mount_watcher_win.cc
index fd3e6a5a4ad969eba086319ab445af72bc3485ad..ba3be1ba98e2b19eedd240f1ee85d01322c6b91b 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";
Lei Zhang 2015/03/03 19:23:50 const char foo[]
tommycli 2015/03/03 19:31:37 Done.
+
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
« no previous file with comments | « components/storage_monitor/volume_mount_watcher_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698