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

Side by Side Diff: chrome/browser/sync_file_system/sync_file_system_service.cc

Issue 900133003: Remove SyncFileSystemservice::GetRemoteService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « chrome/browser/sync_file_system/sync_file_system_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/sync_file_system_service.h" 5 #include "chrome/browser/sync_file_system/sync_file_system_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 316
317 void SyncFileSystemService::DumpDatabase(const DumpFilesCallback& callback) { 317 void SyncFileSystemService::DumpDatabase(const DumpFilesCallback& callback) {
318 remote_service_->DumpDatabase( 318 remote_service_->DumpDatabase(
319 base::Bind(&SyncFileSystemService::DidDumpDatabase, 319 base::Bind(&SyncFileSystemService::DidDumpDatabase,
320 AsWeakPtr(), callback)); 320 AsWeakPtr(), callback));
321 } 321 }
322 322
323 void SyncFileSystemService::GetFileSyncStatus( 323 void SyncFileSystemService::GetFileSyncStatus(
324 const FileSystemURL& url, const SyncFileStatusCallback& callback) { 324 const FileSystemURL& url, const SyncFileStatusCallback& callback) {
325 DCHECK(local_service_); 325 DCHECK(local_service_);
326 DCHECK(GetRemoteService(url.origin())); 326 DCHECK(remote_service_);
327 327
328 // It's possible to get an invalid FileEntry. 328 // It's possible to get an invalid FileEntry.
329 if (!url.is_valid()) { 329 if (!url.is_valid()) {
330 base::ThreadTaskRunnerHandle::Get()->PostTask( 330 base::ThreadTaskRunnerHandle::Get()->PostTask(
331 FROM_HERE, 331 FROM_HERE,
332 base::Bind(callback, 332 base::Bind(callback,
333 SYNC_FILE_ERROR_INVALID_URL, 333 SYNC_FILE_ERROR_INVALID_URL,
334 SYNC_FILE_STATUS_UNKNOWN)); 334 SYNC_FILE_STATUS_UNKNOWN));
335 return; 335 return;
336 } 336 }
337 337
338 local_service_->HasPendingLocalChanges( 338 local_service_->HasPendingLocalChanges(
339 url, 339 url,
340 base::Bind(&SyncFileSystemService::DidGetLocalChangeStatus, 340 base::Bind(&SyncFileSystemService::DidGetLocalChangeStatus,
341 AsWeakPtr(), callback)); 341 AsWeakPtr(), callback));
342 } 342 }
343 343
344 void SyncFileSystemService::AddSyncEventObserver(SyncEventObserver* observer) { 344 void SyncFileSystemService::AddSyncEventObserver(SyncEventObserver* observer) {
345 observers_.AddObserver(observer); 345 observers_.AddObserver(observer);
346 } 346 }
347 347
348 void SyncFileSystemService::RemoveSyncEventObserver( 348 void SyncFileSystemService::RemoveSyncEventObserver(
349 SyncEventObserver* observer) { 349 SyncEventObserver* observer) {
350 observers_.RemoveObserver(observer); 350 observers_.RemoveObserver(observer);
351 } 351 }
352 352
353 LocalChangeProcessor* SyncFileSystemService::GetLocalChangeProcessor( 353 LocalChangeProcessor* SyncFileSystemService::GetLocalChangeProcessor(
354 const GURL& origin) { 354 const GURL& origin) {
355 return GetRemoteService(origin)->GetLocalChangeProcessor(); 355 return remote_service_->GetLocalChangeProcessor();
356 } 356 }
357 357
358 void SyncFileSystemService::OnSyncIdle() { 358 void SyncFileSystemService::OnSyncIdle() {
359 if (promoting_demoted_changes_) 359 if (promoting_demoted_changes_)
360 return; 360 return;
361 promoting_demoted_changes_ = true; 361 promoting_demoted_changes_ = true;
362 362
363 int* job_count = new int(1); 363 int* job_count = new int(1);
364 base::Closure promote_completion_callback = 364 base::Closure promote_completion_callback =
365 base::Bind(&SyncFileSystemService::OnPromotionCompleted, 365 base::Bind(&SyncFileSystemService::OnPromotionCompleted,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 callback.Run(SYNC_STATUS_ABORT); 518 callback.Run(SYNC_STATUS_ABORT);
519 return; 519 return;
520 } 520 }
521 521
522 UMA_HISTOGRAM_ENUMERATION("SyncFileSystem.RegisterOriginResult", 522 UMA_HISTOGRAM_ENUMERATION("SyncFileSystem.RegisterOriginResult",
523 remote_service_->GetCurrentState(), 523 remote_service_->GetCurrentState(),
524 REMOTE_SERVICE_STATE_MAX); 524 REMOTE_SERVICE_STATE_MAX);
525 525
526 if (status == SYNC_STATUS_FAILED) { 526 if (status == SYNC_STATUS_FAILED) {
527 // If we got generic error return the service status information. 527 // If we got generic error return the service status information.
528 switch (GetRemoteService(app_origin)->GetCurrentState()) { 528 switch (remote_service_->GetCurrentState()) {
529 case REMOTE_SERVICE_AUTHENTICATION_REQUIRED: 529 case REMOTE_SERVICE_AUTHENTICATION_REQUIRED:
530 callback.Run(SYNC_STATUS_AUTHENTICATION_FAILED); 530 callback.Run(SYNC_STATUS_AUTHENTICATION_FAILED);
531 return; 531 return;
532 case REMOTE_SERVICE_TEMPORARY_UNAVAILABLE: 532 case REMOTE_SERVICE_TEMPORARY_UNAVAILABLE:
533 callback.Run(SYNC_STATUS_SERVICE_TEMPORARILY_UNAVAILABLE); 533 callback.Run(SYNC_STATUS_SERVICE_TEMPORARILY_UNAVAILABLE);
534 return; 534 return;
535 default: 535 default:
536 break; 536 break;
537 } 537 }
538 } 538 }
(...skipping 10 matching lines...) Expand all
549 if (status != SYNC_STATUS_OK) { 549 if (status != SYNC_STATUS_OK) {
550 callback.Run(base::ListValue()); 550 callback.Run(base::ListValue());
551 return; 551 return;
552 } 552 }
553 553
554 if (!remote_service_) { 554 if (!remote_service_) {
555 callback.Run(base::ListValue()); 555 callback.Run(base::ListValue());
556 return; 556 return;
557 } 557 }
558 558
559 GetRemoteService(origin)->DumpFiles( 559 remote_service_->DumpFiles(
560 origin, 560 origin,
561 base::Bind( 561 base::Bind(
562 &SyncFileSystemService::DidDumpFiles, 562 &SyncFileSystemService::DidDumpFiles,
563 AsWeakPtr(), 563 AsWeakPtr(),
564 origin, 564 origin,
565 callback)); 565 callback));
566 } 566 }
567 567
568 void SyncFileSystemService::DidDumpFiles( 568 void SyncFileSystemService::DidDumpFiles(
569 const GURL& origin, 569 const GURL& origin,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 // handled as enabled origin in the SyncFS. This should be safe and will be 675 // handled as enabled origin in the SyncFS. This should be safe and will be
676 // recovered when the user re-enables the app manually or the sync service 676 // recovered when the user re-enables the app manually or the sync service
677 // restarts. 677 // restarts.
678 DVLOG(1) << "Handle extension notification for UNLOAD(DISABLE_RELOAD): " 678 DVLOG(1) << "Handle extension notification for UNLOAD(DISABLE_RELOAD): "
679 << app_origin; 679 << app_origin;
680 return; 680 return;
681 } 681 }
682 682
683 DVLOG(1) << "Handle extension notification for UNLOAD(DISABLE): " 683 DVLOG(1) << "Handle extension notification for UNLOAD(DISABLE): "
684 << app_origin; 684 << app_origin;
685 GetRemoteService(app_origin)->DisableOrigin( 685 remote_service_->DisableOrigin(
686 app_origin, 686 app_origin,
687 base::Bind(&DidHandleUnloadedEvent, app_origin)); 687 base::Bind(&DidHandleUnloadedEvent, app_origin));
688 local_service_->SetOriginEnabled(app_origin, false); 688 local_service_->SetOriginEnabled(app_origin, false);
689 } 689 }
690 690
691 void SyncFileSystemService::OnExtensionUninstalled( 691 void SyncFileSystemService::OnExtensionUninstalled(
692 content::BrowserContext* browser_context, 692 content::BrowserContext* browser_context,
693 const Extension* extension, 693 const Extension* extension,
694 extensions::UninstallReason reason) { 694 extensions::UninstallReason reason) {
695 RemoteFileSyncService::UninstallFlag flag = 695 RemoteFileSyncService::UninstallFlag flag =
696 RemoteFileSyncService::UNINSTALL_AND_PURGE_REMOTE; 696 RemoteFileSyncService::UNINSTALL_AND_PURGE_REMOTE;
697 // If it's loaded from an unpacked package and with key: field, 697 // If it's loaded from an unpacked package and with key: field,
698 // the uninstall will not be sync'ed and the user might be using the 698 // the uninstall will not be sync'ed and the user might be using the
699 // same app key in other installs, so avoid purging the remote folder. 699 // same app key in other installs, so avoid purging the remote folder.
700 if (extensions::Manifest::IsUnpackedLocation(extension->location()) && 700 if (extensions::Manifest::IsUnpackedLocation(extension->location()) &&
701 extension->manifest()->HasKey(extensions::manifest_keys::kKey)) { 701 extension->manifest()->HasKey(extensions::manifest_keys::kKey)) {
702 flag = RemoteFileSyncService::UNINSTALL_AND_KEEP_REMOTE; 702 flag = RemoteFileSyncService::UNINSTALL_AND_KEEP_REMOTE;
703 } 703 }
704 704
705 GURL app_origin = Extension::GetBaseURLFromExtensionId(extension->id()); 705 GURL app_origin = Extension::GetBaseURLFromExtensionId(extension->id());
706 DVLOG(1) << "Handle extension notification for UNINSTALLED: " 706 DVLOG(1) << "Handle extension notification for UNINSTALLED: "
707 << app_origin; 707 << app_origin;
708 GetRemoteService(app_origin)->UninstallOrigin( 708 remote_service_->UninstallOrigin(
709 app_origin, flag, 709 app_origin, flag,
710 base::Bind(&DidHandleUninstalledEvent, app_origin)); 710 base::Bind(&DidHandleUninstalledEvent, app_origin));
711 local_service_->SetOriginEnabled(app_origin, false); 711 local_service_->SetOriginEnabled(app_origin, false);
712 } 712 }
713 713
714 void SyncFileSystemService::OnExtensionLoaded( 714 void SyncFileSystemService::OnExtensionLoaded(
715 content::BrowserContext* browser_context, 715 content::BrowserContext* browser_context,
716 const Extension* extension) { 716 const Extension* extension) {
717 GURL app_origin = Extension::GetBaseURLFromExtensionId(extension->id()); 717 GURL app_origin = Extension::GetBaseURLFromExtensionId(extension->id());
718 DVLOG(1) << "Handle extension notification for LOADED: " << app_origin; 718 DVLOG(1) << "Handle extension notification for LOADED: " << app_origin;
719 GetRemoteService(app_origin)->EnableOrigin( 719 remote_service_->EnableOrigin(
720 app_origin, 720 app_origin,
721 base::Bind(&DidHandleLoadEvent, app_origin)); 721 base::Bind(&DidHandleLoadEvent, app_origin));
722 local_service_->SetOriginEnabled(app_origin, true); 722 local_service_->SetOriginEnabled(app_origin, true);
723 } 723 }
724 724
725 void SyncFileSystemService::OnStateChanged() { 725 void SyncFileSystemService::OnStateChanged() {
726 ProfileSyncServiceBase* profile_sync_service = 726 ProfileSyncServiceBase* profile_sync_service =
727 ProfileSyncServiceFactory::GetForProfile(profile_); 727 ProfileSyncServiceFactory::GetForProfile(profile_);
728 if (profile_sync_service) 728 if (profile_sync_service)
729 UpdateSyncEnabledStatus(profile_sync_service); 729 UpdateSyncEnabledStatus(profile_sync_service);
(...skipping 27 matching lines...) Expand all
757 for (ScopedVector<SyncProcessRunner>::iterator iter = 757 for (ScopedVector<SyncProcessRunner>::iterator iter =
758 local_sync_runners_.begin(); 758 local_sync_runners_.begin();
759 iter != local_sync_runners_.end(); ++iter) 759 iter != local_sync_runners_.end(); ++iter)
760 ((*iter)->*method)(); 760 ((*iter)->*method)();
761 for (ScopedVector<SyncProcessRunner>::iterator iter = 761 for (ScopedVector<SyncProcessRunner>::iterator iter =
762 remote_sync_runners_.begin(); 762 remote_sync_runners_.begin();
763 iter != remote_sync_runners_.end(); ++iter) 763 iter != remote_sync_runners_.end(); ++iter)
764 ((*iter)->*method)(); 764 ((*iter)->*method)();
765 } 765 }
766 766
767 RemoteFileSyncService* SyncFileSystemService::GetRemoteService(
768 const GURL& origin) {
769 return remote_service_.get();
770 }
771
772 } // namespace sync_file_system 767 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/sync_file_system_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698