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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/sync_engine.cc

Issue 190243003: [SyncFS] Move FROM_HEREs in SyncTaskManager to its client (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 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_engine_unittest.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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/threading/sequenced_worker_pool.h" 8 #include "base/threading/sequenced_worker_pool.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/drive/drive_api_service.h" 10 #include "chrome/browser/drive/drive_api_service.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if (!metadata_database_ && drive_service_->HasRefreshToken()) 158 if (!metadata_database_ && drive_service_->HasRefreshToken())
159 PostInitializeTask(); 159 PostInitializeTask();
160 160
161 scoped_ptr<RegisterAppTask> task(new RegisterAppTask(this, origin.host())); 161 scoped_ptr<RegisterAppTask> task(new RegisterAppTask(this, origin.host()));
162 if (task->CanFinishImmediately()) { 162 if (task->CanFinishImmediately()) {
163 callback.Run(SYNC_STATUS_OK); 163 callback.Run(SYNC_STATUS_OK);
164 return; 164 return;
165 } 165 }
166 166
167 task_manager_->ScheduleSyncTaskAtPriority( 167 task_manager_->ScheduleSyncTaskAtPriority(
168 task.PassAs<SyncTask>(), SyncTaskManager::PRIORITY_HIGH, callback); 168 FROM_HERE,
169 task.PassAs<SyncTask>(),
170 SyncTaskManager::PRIORITY_HIGH,
171 callback);
169 } 172 }
170 173
171 void SyncEngine::EnableOrigin( 174 void SyncEngine::EnableOrigin(
172 const GURL& origin, 175 const GURL& origin,
173 const SyncStatusCallback& callback) { 176 const SyncStatusCallback& callback) {
174 task_manager_->ScheduleTaskAtPriority( 177 task_manager_->ScheduleTaskAtPriority(
178 FROM_HERE,
175 base::Bind(&SyncEngine::DoEnableApp, 179 base::Bind(&SyncEngine::DoEnableApp,
176 weak_ptr_factory_.GetWeakPtr(), 180 weak_ptr_factory_.GetWeakPtr(),
177 origin.host()), 181 origin.host()),
178 SyncTaskManager::PRIORITY_HIGH, 182 SyncTaskManager::PRIORITY_HIGH,
179 callback); 183 callback);
180 } 184 }
181 185
182 void SyncEngine::DisableOrigin( 186 void SyncEngine::DisableOrigin(
183 const GURL& origin, 187 const GURL& origin,
184 const SyncStatusCallback& callback) { 188 const SyncStatusCallback& callback) {
185 task_manager_->ScheduleTaskAtPriority( 189 task_manager_->ScheduleTaskAtPriority(
190 FROM_HERE,
186 base::Bind(&SyncEngine::DoDisableApp, 191 base::Bind(&SyncEngine::DoDisableApp,
187 weak_ptr_factory_.GetWeakPtr(), 192 weak_ptr_factory_.GetWeakPtr(),
188 origin.host()), 193 origin.host()),
189 SyncTaskManager::PRIORITY_HIGH, 194 SyncTaskManager::PRIORITY_HIGH,
190 callback); 195 callback);
191 } 196 }
192 197
193 void SyncEngine::UninstallOrigin( 198 void SyncEngine::UninstallOrigin(
194 const GURL& origin, 199 const GURL& origin,
195 UninstallFlag flag, 200 UninstallFlag flag,
196 const SyncStatusCallback& callback) { 201 const SyncStatusCallback& callback) {
197 task_manager_->ScheduleSyncTaskAtPriority( 202 task_manager_->ScheduleSyncTaskAtPriority(
203 FROM_HERE,
198 scoped_ptr<SyncTask>(new UninstallAppTask(this, origin.host(), flag)), 204 scoped_ptr<SyncTask>(new UninstallAppTask(this, origin.host(), flag)),
199 SyncTaskManager::PRIORITY_HIGH, 205 SyncTaskManager::PRIORITY_HIGH,
200 callback); 206 callback);
201 } 207 }
202 208
203 void SyncEngine::ProcessRemoteChange( 209 void SyncEngine::ProcessRemoteChange(
204 const SyncFileCallback& callback) { 210 const SyncFileCallback& callback) {
205 RemoteToLocalSyncer* syncer = new RemoteToLocalSyncer(this); 211 RemoteToLocalSyncer* syncer = new RemoteToLocalSyncer(this);
206 task_manager_->ScheduleSyncTask( 212 task_manager_->ScheduleSyncTask(
213 FROM_HERE,
207 scoped_ptr<SyncTask>(syncer), 214 scoped_ptr<SyncTask>(syncer),
208 base::Bind(&SyncEngine::DidProcessRemoteChange, 215 base::Bind(&SyncEngine::DidProcessRemoteChange,
209 weak_ptr_factory_.GetWeakPtr(), 216 weak_ptr_factory_.GetWeakPtr(),
210 syncer, callback)); 217 syncer, callback));
211 } 218 }
212 219
213 void SyncEngine::SetRemoteChangeProcessor( 220 void SyncEngine::SetRemoteChangeProcessor(
214 RemoteChangeProcessor* processor) { 221 RemoteChangeProcessor* processor) {
215 remote_change_processor_ = processor; 222 remote_change_processor_ = processor;
216 } 223 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 335
329 void SyncEngine::ApplyLocalChange( 336 void SyncEngine::ApplyLocalChange(
330 const FileChange& local_change, 337 const FileChange& local_change,
331 const base::FilePath& local_path, 338 const base::FilePath& local_path,
332 const SyncFileMetadata& local_metadata, 339 const SyncFileMetadata& local_metadata,
333 const fileapi::FileSystemURL& url, 340 const fileapi::FileSystemURL& url,
334 const SyncStatusCallback& callback) { 341 const SyncStatusCallback& callback) {
335 LocalToRemoteSyncer* syncer = new LocalToRemoteSyncer( 342 LocalToRemoteSyncer* syncer = new LocalToRemoteSyncer(
336 this, local_metadata, local_change, local_path, url); 343 this, local_metadata, local_change, local_path, url);
337 task_manager_->ScheduleSyncTask( 344 task_manager_->ScheduleSyncTask(
345 FROM_HERE,
338 scoped_ptr<SyncTask>(syncer), 346 scoped_ptr<SyncTask>(syncer),
339 base::Bind(&SyncEngine::DidApplyLocalChange, 347 base::Bind(&SyncEngine::DidApplyLocalChange,
340 weak_ptr_factory_.GetWeakPtr(), 348 weak_ptr_factory_.GetWeakPtr(),
341 syncer, callback)); 349 syncer, callback));
342 } 350 }
343 351
344 void SyncEngine::MaybeScheduleNextTask() { 352 void SyncEngine::MaybeScheduleNextTask() {
345 if (GetCurrentState() == REMOTE_SERVICE_DISABLED) 353 if (GetCurrentState() == REMOTE_SERVICE_DISABLED)
346 return; 354 return;
347 355
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 491
484 // This initializer task may not run if metadata_database_ is already 492 // This initializer task may not run if metadata_database_ is already
485 // initialized when it runs. 493 // initialized when it runs.
486 SyncEngineInitializer* initializer = 494 SyncEngineInitializer* initializer =
487 new SyncEngineInitializer(this, 495 new SyncEngineInitializer(this,
488 task_runner_.get(), 496 task_runner_.get(),
489 drive_service_.get(), 497 drive_service_.get(),
490 base_dir_.Append(kDatabaseName), 498 base_dir_.Append(kDatabaseName),
491 env_override_); 499 env_override_);
492 task_manager_->ScheduleSyncTaskAtPriority( 500 task_manager_->ScheduleSyncTaskAtPriority(
501 FROM_HERE,
493 scoped_ptr<SyncTask>(initializer), 502 scoped_ptr<SyncTask>(initializer),
494 SyncTaskManager::PRIORITY_HIGH, 503 SyncTaskManager::PRIORITY_HIGH,
495 base::Bind(&SyncEngine::DidInitialize, weak_ptr_factory_.GetWeakPtr(), 504 base::Bind(&SyncEngine::DidInitialize, weak_ptr_factory_.GetWeakPtr(),
496 initializer)); 505 initializer));
497 } 506 }
498 507
499 void SyncEngine::DidInitialize(SyncEngineInitializer* initializer, 508 void SyncEngine::DidInitialize(SyncEngineInitializer* initializer,
500 SyncStatusCode status) { 509 SyncStatusCode status) {
501 if (status != SYNC_STATUS_OK) { 510 if (status != SYNC_STATUS_OK) {
502 if (drive_service_->HasRefreshToken()) { 511 if (drive_service_->HasRefreshToken()) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 578 }
570 579
571 if (status == SYNC_STATUS_UNKNOWN_ORIGIN && syncer->url().is_valid()) { 580 if (status == SYNC_STATUS_UNKNOWN_ORIGIN && syncer->url().is_valid()) {
572 RegisterOrigin(syncer->url().origin(), 581 RegisterOrigin(syncer->url().origin(),
573 base::Bind(&EmptyStatusCallback)); 582 base::Bind(&EmptyStatusCallback));
574 } 583 }
575 584
576 if (syncer->needs_remote_change_listing() && 585 if (syncer->needs_remote_change_listing() &&
577 !listing_remote_changes_) { 586 !listing_remote_changes_) {
578 task_manager_->ScheduleSyncTaskAtPriority( 587 task_manager_->ScheduleSyncTaskAtPriority(
588 FROM_HERE,
579 scoped_ptr<SyncTask>(new ListChangesTask(this)), 589 scoped_ptr<SyncTask>(new ListChangesTask(this)),
580 SyncTaskManager::PRIORITY_HIGH, 590 SyncTaskManager::PRIORITY_HIGH,
581 base::Bind(&SyncEngine::DidFetchChanges, 591 base::Bind(&SyncEngine::DidFetchChanges,
582 weak_ptr_factory_.GetWeakPtr())); 592 weak_ptr_factory_.GetWeakPtr()));
583 should_check_remote_change_ = false; 593 should_check_remote_change_ = false;
584 listing_remote_changes_ = true; 594 listing_remote_changes_ = true;
585 time_to_check_changes_ = 595 time_to_check_changes_ =
586 base::TimeTicks::Now() + 596 base::TimeTicks::Now() +
587 base::TimeDelta::FromSeconds(kListChangesRetryDelaySeconds); 597 base::TimeDelta::FromSeconds(kListChangesRetryDelaySeconds);
588 } 598 }
(...skipping 18 matching lines...) Expand all
607 return; 617 return;
608 618
609 if (listing_remote_changes_) 619 if (listing_remote_changes_)
610 return; 620 return;
611 621
612 base::TimeTicks now = base::TimeTicks::Now(); 622 base::TimeTicks now = base::TimeTicks::Now();
613 if (!should_check_remote_change_ && now < time_to_check_changes_) { 623 if (!should_check_remote_change_ && now < time_to_check_changes_) {
614 if (!metadata_database_->HasDirtyTracker() && should_check_conflict_) { 624 if (!metadata_database_->HasDirtyTracker() && should_check_conflict_) {
615 should_check_conflict_ = false; 625 should_check_conflict_ = false;
616 task_manager_->ScheduleSyncTaskIfIdle( 626 task_manager_->ScheduleSyncTaskIfIdle(
627 FROM_HERE,
617 scoped_ptr<SyncTask>(new ConflictResolver(this)), 628 scoped_ptr<SyncTask>(new ConflictResolver(this)),
618 base::Bind(&SyncEngine::DidResolveConflict, 629 base::Bind(&SyncEngine::DidResolveConflict,
619 weak_ptr_factory_.GetWeakPtr())); 630 weak_ptr_factory_.GetWeakPtr()));
620 } 631 }
621 return; 632 return;
622 } 633 }
623 634
624 if (task_manager_->ScheduleSyncTaskIfIdle( 635 if (task_manager_->ScheduleSyncTaskIfIdle(
636 FROM_HERE,
625 scoped_ptr<SyncTask>(new ListChangesTask(this)), 637 scoped_ptr<SyncTask>(new ListChangesTask(this)),
626 base::Bind(&SyncEngine::DidFetchChanges, 638 base::Bind(&SyncEngine::DidFetchChanges,
627 weak_ptr_factory_.GetWeakPtr()))) { 639 weak_ptr_factory_.GetWeakPtr()))) {
628 should_check_remote_change_ = false; 640 should_check_remote_change_ = false;
629 listing_remote_changes_ = true; 641 listing_remote_changes_ = true;
630 time_to_check_changes_ = 642 time_to_check_changes_ =
631 now + base::TimeDelta::FromSeconds(kListChangesRetryDelaySeconds); 643 now + base::TimeDelta::FromSeconds(kListChangesRetryDelaySeconds);
632 } 644 }
633 } 645 }
634 646
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT; 753 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT;
742 if (is_app_enabled && !is_app_root_tracker_enabled) 754 if (is_app_enabled && !is_app_root_tracker_enabled)
743 EnableOrigin(origin, base::Bind(&EmptyStatusCallback)); 755 EnableOrigin(origin, base::Bind(&EmptyStatusCallback));
744 else if (!is_app_enabled && is_app_root_tracker_enabled) 756 else if (!is_app_enabled && is_app_root_tracker_enabled)
745 DisableOrigin(origin, base::Bind(&EmptyStatusCallback)); 757 DisableOrigin(origin, base::Bind(&EmptyStatusCallback));
746 } 758 }
747 } 759 }
748 760
749 } // namespace drive_backend 761 } // namespace drive_backend
750 } // namespace sync_file_system 762 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_backend/sync_engine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698