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

Unified Diff: chrome/browser/sync_file_system/drive_backend/sync_worker.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: Removed RunLoop 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
Index: chrome/browser/sync_file_system/drive_backend/sync_worker.cc
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_worker.cc b/chrome/browser/sync_file_system/drive_backend/sync_worker.cc
index c2b7f87f6c4845a891b87221d8f8b1b5d3f5d626..3bd73207b1754eb5a1dd5b18e819628f137a790b 100644
--- a/chrome/browser/sync_file_system/drive_backend/sync_worker.cc
+++ b/chrome/browser/sync_file_system/drive_backend/sync_worker.cc
@@ -85,6 +85,7 @@ void QueryAppStatusOnUIThread(
} // namespace
+// static
scoped_ptr<SyncWorker> SyncWorker::CreateOnWorker(
const base::FilePath& base_dir,
Observer* observer,
@@ -97,7 +98,6 @@ scoped_ptr<SyncWorker> SyncWorker::CreateOnWorker(
sync_engine_context.Pass(),
env_override));
sync_worker->AddObserver(observer);
- sync_worker->Initialize();
return sync_worker.Pass();
}
@@ -108,7 +108,8 @@ void SyncWorker::Initialize() {
DCHECK(!task_manager_);
task_manager_.reset(new SyncTaskManager(
- weak_ptr_factory_.GetWeakPtr(), 0 /* maximum_background_task */));
+ AsWeakPtr(),
+ 0 /* maximum_background_task */));
task_manager_->Initialize(SYNC_STATUS_OK);
PostInitializeTask();
@@ -133,7 +134,6 @@ void SyncWorker::RegisterOrigin(
return;
}
- // TODO(peria): Forward |callback| to UI thread.
task_manager_->ScheduleSyncTask(
FROM_HERE,
task.PassAs<SyncTask>(),
@@ -144,11 +144,10 @@ void SyncWorker::RegisterOrigin(
void SyncWorker::EnableOrigin(
const GURL& origin,
const SyncStatusCallback& callback) {
- // TODO(peria): Forward |callback| to UI thread.
task_manager_->ScheduleTask(
FROM_HERE,
base::Bind(&SyncWorker::DoEnableApp,
- weak_ptr_factory_.GetWeakPtr(),
+ AsWeakPtr(),
origin.host()),
SyncTaskManager::PRIORITY_HIGH,
callback);
@@ -157,11 +156,10 @@ void SyncWorker::EnableOrigin(
void SyncWorker::DisableOrigin(
const GURL& origin,
const SyncStatusCallback& callback) {
- // TODO(peria): Forward |callback| to UI thread.
task_manager_->ScheduleTask(
FROM_HERE,
base::Bind(&SyncWorker::DoDisableApp,
- weak_ptr_factory_.GetWeakPtr(),
+ AsWeakPtr(),
origin.host()),
SyncTaskManager::PRIORITY_HIGH,
callback);
@@ -171,7 +169,6 @@ void SyncWorker::UninstallOrigin(
const GURL& origin,
RemoteFileSyncService::UninstallFlag flag,
const SyncStatusCallback& callback) {
- // TODO(peria): Forward |callback| to UI thread.
task_manager_->ScheduleSyncTask(
FROM_HERE,
scoped_ptr<SyncTask>(
@@ -188,7 +185,7 @@ void SyncWorker::ProcessRemoteChange(
scoped_ptr<SyncTask>(syncer),
SyncTaskManager::PRIORITY_MED,
base::Bind(&SyncWorker::DidProcessRemoteChange,
- weak_ptr_factory_.GetWeakPtr(),
+ AsWeakPtr(),
syncer, callback));
}
@@ -290,7 +287,7 @@ void SyncWorker::ApplyLocalChange(
scoped_ptr<SyncTask>(syncer),
SyncTaskManager::PRIORITY_MED,
base::Bind(&SyncWorker::DidApplyLocalChange,
- weak_ptr_factory_.GetWeakPtr(),
+ AsWeakPtr(),
syncer, callback));
}
@@ -397,8 +394,7 @@ SyncWorker::SyncWorker(
CONFLICT_RESOLUTION_POLICY_LAST_WRITE_WIN),
network_available_(false),
extension_service_(extension_service),
- context_(sync_engine_context.Pass()),
- weak_ptr_factory_(this) {}
+ context_(sync_engine_context.Pass()) {}
void SyncWorker::DoDisableApp(const std::string& app_id,
const SyncStatusCallback& callback) {
@@ -434,7 +430,7 @@ void SyncWorker::PostInitializeTask() {
scoped_ptr<SyncTask>(initializer),
SyncTaskManager::PRIORITY_HIGH,
base::Bind(&SyncWorker::DidInitialize,
- weak_ptr_factory_.GetWeakPtr(),
+ AsWeakPtr(),
initializer));
}
@@ -469,7 +465,7 @@ void SyncWorker::UpdateRegisteredApp() {
AppStatusMap* app_status = new AppStatusMap;
base::Closure callback =
base::Bind(&SyncWorker::DidQueryAppStatus,
- weak_ptr_factory_.GetWeakPtr(),
+ AsWeakPtr(),
base::Owned(app_status));
context_->GetUITaskRunner()->PostTask(
@@ -583,7 +579,7 @@ void SyncWorker::DidApplyLocalChange(LocalToRemoteSyncer* syncer,
scoped_ptr<SyncTask>(new ListChangesTask(context_.get())),
SyncTaskManager::PRIORITY_HIGH,
base::Bind(&SyncWorker::DidFetchChanges,
- weak_ptr_factory_.GetWeakPtr()));
+ AsWeakPtr()));
should_check_remote_change_ = false;
listing_remote_changes_ = true;
time_to_check_changes_ =
@@ -616,7 +612,7 @@ void SyncWorker::MaybeStartFetchChanges() {
FROM_HERE,
scoped_ptr<SyncTask>(new ConflictResolver(context_.get())),
base::Bind(&SyncWorker::DidResolveConflict,
- weak_ptr_factory_.GetWeakPtr()));
+ AsWeakPtr()));
}
return;
}
@@ -625,7 +621,7 @@ void SyncWorker::MaybeStartFetchChanges() {
FROM_HERE,
scoped_ptr<SyncTask>(new ListChangesTask(context_.get())),
base::Bind(&SyncWorker::DidFetchChanges,
- weak_ptr_factory_.GetWeakPtr()))) {
+ AsWeakPtr()))) {
should_check_remote_change_ = false;
listing_remote_changes_ = true;
time_to_check_changes_ =

Powered by Google App Engine
This is Rietveld 408576698