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

Unified Diff: chrome/browser/sync_file_system/drive_backend/sync_engine.cc

Issue 288193002: [SyncFS] Construct and destruct sync_worker in worker_task_runner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Work for a nit, from offline chat Created 6 years, 7 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 | « no previous file | chrome/browser/sync_file_system/drive_backend/sync_worker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync_file_system/drive_backend/sync_engine.cc
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc
index be3a51a18477c1f3ae973dd9d3b7ed15d643fffe..d24cda6f4df28c3ccba19ec05c17806b504bf207 100644
--- a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc
+++ b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc
@@ -205,7 +205,13 @@ SyncEngine::~SyncEngine() {
if (notification_manager_)
notification_manager_->RemoveObserver(this);
- // TODO(tzik): Destroy |sync_worker_| and |worker_observer_| on the worker.
+ WorkerObserver* worker_observer = worker_observer_.release();
+ if (!worker_task_runner_->DeleteSoon(FROM_HERE, worker_observer))
+ delete worker_observer;
+
+ SyncWorker* sync_worker = sync_worker_.release();
+ if (!worker_task_runner_->DeleteSoon(FROM_HERE, sync_worker))
+ delete sync_worker;
}
void SyncEngine::Initialize(const base::FilePath& base_dir,
@@ -239,13 +245,16 @@ void SyncEngine::Initialize(const base::FilePath& base_dir,
if (extension_service_)
extension_service_weak_ptr = extension_service_->AsWeakPtr();
- // TODO(peria): Use PostTask on |worker_task_runner_| to call this function.
- sync_worker_ = SyncWorker::CreateOnWorker(
+ sync_worker_.reset(new SyncWorker(
base_dir,
- worker_observer_.get(),
extension_service_weak_ptr,
sync_engine_context.Pass(),
- env_override);
+ env_override));
+ sync_worker_->AddObserver(worker_observer_.get());
+ worker_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&SyncWorker::Initialize,
+ base::Unretained(sync_worker_.get())));
if (notification_manager_)
notification_manager_->AddObserver(this);
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_backend/sync_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698