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

Side by Side 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 comments 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_backend/sync_worker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h" 5 #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 factories->insert( 198 factories->insert(
199 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 199 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
200 } 200 }
201 201
202 SyncEngine::~SyncEngine() { 202 SyncEngine::~SyncEngine() {
203 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); 203 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
204 GetDriveService()->RemoveObserver(this); 204 GetDriveService()->RemoveObserver(this);
205 if (notification_manager_) 205 if (notification_manager_)
206 notification_manager_->RemoveObserver(this); 206 notification_manager_->RemoveObserver(this);
207 207
208 // TODO(tzik): Destroy |sync_worker_| and |worker_observer_| on the worker. 208 worker_task_runner_->DeleteSoon(FROM_HERE, worker_observer_.release());
209 worker_task_runner_->DeleteSoon(FROM_HERE, sync_worker_.release());
209 } 210 }
210 211
211 void SyncEngine::Initialize(const base::FilePath& base_dir, 212 void SyncEngine::Initialize(const base::FilePath& base_dir,
212 base::SequencedTaskRunner* file_task_runner, 213 base::SequencedTaskRunner* file_task_runner,
213 leveldb::Env* env_override) { 214 leveldb::Env* env_override) {
214 // DriveServiceWrapper and DriveServiceOnWorker relay communications 215 // DriveServiceWrapper and DriveServiceOnWorker relay communications
215 // between DriveService and syncers in SyncWorker. 216 // between DriveService and syncers in SyncWorker.
216 scoped_ptr<drive::DriveServiceInterface> 217 scoped_ptr<drive::DriveServiceInterface>
217 drive_service_on_worker( 218 drive_service_on_worker(
218 new DriveServiceOnWorker(drive_service_wrapper_->AsWeakPtr(), 219 new DriveServiceOnWorker(drive_service_wrapper_->AsWeakPtr(),
(...skipping 13 matching lines...) Expand all
232 file_task_runner)); 233 file_task_runner));
233 234
234 worker_observer_.reset( 235 worker_observer_.reset(
235 new WorkerObserver(base::MessageLoopProxy::current(), 236 new WorkerObserver(base::MessageLoopProxy::current(),
236 weak_ptr_factory_.GetWeakPtr())); 237 weak_ptr_factory_.GetWeakPtr()));
237 238
238 base::WeakPtr<ExtensionServiceInterface> extension_service_weak_ptr; 239 base::WeakPtr<ExtensionServiceInterface> extension_service_weak_ptr;
239 if (extension_service_) 240 if (extension_service_)
240 extension_service_weak_ptr = extension_service_->AsWeakPtr(); 241 extension_service_weak_ptr = extension_service_->AsWeakPtr();
241 242
242 // TODO(peria): Use PostTask on |worker_task_runner_| to call this function.
243 sync_worker_ = SyncWorker::CreateOnWorker( 243 sync_worker_ = SyncWorker::CreateOnWorker(
nhiroki 2014/05/26 08:06:03 How about renaming this or calling the ctor direct
peria 2014/05/26 08:14:41 Done.
244 base_dir, 244 base_dir,
245 worker_observer_.get(), 245 worker_observer_.get(),
246 extension_service_weak_ptr, 246 extension_service_weak_ptr,
247 sync_engine_context.Pass(), 247 sync_engine_context.Pass(),
248 env_override); 248 env_override);
249 249
250 if (notification_manager_) 250 if (notification_manager_)
251 notification_manager_->AddObserver(this); 251 notification_manager_->AddObserver(this);
252 GetDriveService()->AddObserver(this); 252 GetDriveService()->AddObserver(this);
253 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); 253 net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
254
255 worker_task_runner_->PostTask(
256 FROM_HERE,
257 base::Bind(&SyncWorker::Initialize,
258 base::Unretained(sync_worker_.get())));
nhiroki 2014/05/26 08:06:03 You may want to move this to line 249 for readabil
peria 2014/05/26 08:14:41 Done.
254 } 259 }
255 260
256 void SyncEngine::AddServiceObserver(SyncServiceObserver* observer) { 261 void SyncEngine::AddServiceObserver(SyncServiceObserver* observer) {
257 service_observers_.AddObserver(observer); 262 service_observers_.AddObserver(observer);
258 } 263 }
259 264
260 void SyncEngine::AddFileStatusObserver(FileStatusObserver* observer) { 265 void SyncEngine::AddFileStatusObserver(FileStatusObserver* observer) {
261 file_status_observers_.AddObserver(observer); 266 file_status_observers_.AddObserver(observer);
262 } 267 }
263 268
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT; 545 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT;
541 if (is_app_enabled && !is_app_root_tracker_enabled) 546 if (is_app_enabled && !is_app_root_tracker_enabled)
542 EnableOrigin(origin, base::Bind(&EmptyStatusCallback)); 547 EnableOrigin(origin, base::Bind(&EmptyStatusCallback));
543 else if (!is_app_enabled && is_app_root_tracker_enabled) 548 else if (!is_app_enabled && is_app_root_tracker_enabled)
544 DisableOrigin(origin, base::Bind(&EmptyStatusCallback)); 549 DisableOrigin(origin, base::Bind(&EmptyStatusCallback));
545 } 550 }
546 } 551 }
547 552
548 } // namespace drive_backend 553 } // namespace drive_backend
549 } // namespace sync_file_system 554 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_backend/sync_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698