Commit 385e3940 authored by tommycli's avatar tommycli Committed by Commit bot

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}
parent 3611ddb2
......@@ -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.
......
......@@ -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
......@@ -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_;
......
......@@ -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
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment