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

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

Issue 294893005: [SyncFS] Make GetOriginStatusMap asynchronous (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactoring 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
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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 base::Bind(&SyncFileSystemService::DidInitializeFileSystem, 298 base::Bind(&SyncFileSystemService::DidInitializeFileSystem,
299 AsWeakPtr(), app_origin, callback)); 299 AsWeakPtr(), app_origin, callback));
300 } 300 }
301 301
302 SyncServiceState SyncFileSystemService::GetSyncServiceState() { 302 SyncServiceState SyncFileSystemService::GetSyncServiceState() {
303 // For now we always query the state from the main RemoteFileSyncService. 303 // For now we always query the state from the main RemoteFileSyncService.
304 return RemoteStateToSyncServiceState(remote_service_->GetCurrentState()); 304 return RemoteStateToSyncServiceState(remote_service_->GetCurrentState());
305 } 305 }
306 306
307 void SyncFileSystemService::GetExtensionStatusMap( 307 void SyncFileSystemService::GetExtensionStatusMap(
308 std::map<GURL, std::string>* status_map) { 308 const RemoteFileSyncService::StatusMapCallback& callback) {
309 DCHECK(status_map); 309 remote_service_->GetOriginStatusMap(
310 status_map->clear(); 310 base::Bind(&SyncFileSystemService::DidGetExtensionStatusMap,
311 remote_service_->GetOriginStatusMap(status_map); 311 AsWeakPtr(), callback));
312 if (v2_remote_service_)
313 v2_remote_service_->GetOriginStatusMap(status_map);
314 } 312 }
315 313
316 void SyncFileSystemService::DumpFiles(const GURL& origin, 314 void SyncFileSystemService::DumpFiles(const GURL& origin,
317 const DumpFilesCallback& callback) { 315 const DumpFilesCallback& callback) {
318 DCHECK(!origin.is_empty()); 316 DCHECK(!origin.is_empty());
319 317
320 content::StoragePartition* storage_partition = 318 content::StoragePartition* storage_partition =
321 content::BrowserContext::GetStoragePartitionForSite(profile_, origin); 319 content::BrowserContext::GetStoragePartitionForSite(profile_, origin);
322 fileapi::FileSystemContext* file_system_context = 320 fileapi::FileSystemContext* file_system_context =
323 storage_partition->GetFileSystemContext(); 321 storage_partition->GetFileSystemContext();
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 itr != v2list->end();) { 569 itr != v2list->end();) {
572 scoped_ptr<base::Value> item; 570 scoped_ptr<base::Value> item;
573 itr = v2list->Erase(itr, &item); 571 itr = v2list->Erase(itr, &item);
574 v1list->Append(item.release()); 572 v1list->Append(item.release());
575 } 573 }
576 } 574 }
577 575
578 callback.Run(*v1list); 576 callback.Run(*v1list);
579 } 577 }
580 578
579 void SyncFileSystemService::DidGetExtensionStatusMap(
580 const RemoteFileSyncService::StatusMapCallback& callback,
581 const RemoteFileSyncService::OriginStatusMap& status_map) {
582 if (!v2_remote_service_) {
583 callback.Run(status_map);
584 return;
585 }
586
587 v2_remote_service_->GetOriginStatusMap(
588 base::Bind(&SyncFileSystemService::DidGetV2ExtensionStatusMap,
589 AsWeakPtr(), callback, status_map));
590 }
591
592 void SyncFileSystemService::DidGetV2ExtensionStatusMap(
593 const RemoteFileSyncService::StatusMapCallback& callback,
594 const RemoteFileSyncService::OriginStatusMap& status_map_v1,
595 const RemoteFileSyncService::OriginStatusMap& status_map_v2) {
596 // Merge |status_map_v2| into |status_map_v1|.
597 std::map<GURL, std::string> status_map(status_map_v1);
598 for (std::map<GURL, std::string>::const_iterator itr = status_map_v2.begin();
599 itr != status_map_v2.end(); ++itr)
600 status_map.insert(*itr);
tzik 2014/05/21 10:52:33 I think just status_map.insert(status_map_v2.begin
peria 2014/05/22 02:25:21 Done.
601
602 callback.Run(status_map);
603 }
604
581 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) { 605 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) {
582 sync_enabled_ = enabled; 606 sync_enabled_ = enabled;
583 remote_service_->SetSyncEnabled(sync_enabled_); 607 remote_service_->SetSyncEnabled(sync_enabled_);
584 if (v2_remote_service_) 608 if (v2_remote_service_)
585 v2_remote_service_->SetSyncEnabled(sync_enabled_); 609 v2_remote_service_->SetSyncEnabled(sync_enabled_);
586 } 610 }
587 611
588 void SyncFileSystemService::DidGetLocalChangeStatus( 612 void SyncFileSystemService::DidGetLocalChangeStatus(
589 const SyncFileStatusCallback& callback, 613 const SyncFileStatusCallback& callback,
590 SyncStatusCode status, 614 SyncStatusCode status,
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get()); 829 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get());
806 v2_remote_service_->SetSyncEnabled(sync_enabled_); 830 v2_remote_service_->SetSyncEnabled(sync_enabled_);
807 v2_remote_service_->SetDefaultConflictResolutionPolicy( 831 v2_remote_service_->SetDefaultConflictResolutionPolicy(
808 remote_service_->GetDefaultConflictResolutionPolicy()); 832 remote_service_->GetDefaultConflictResolutionPolicy());
809 remote_sync_runners_.push_back(v2_remote_syncer.release()); 833 remote_sync_runners_.push_back(v2_remote_syncer.release());
810 } 834 }
811 return v2_remote_service_.get(); 835 return v2_remote_service_.get();
812 } 836 }
813 837
814 } // namespace sync_file_system 838 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698