OLD | NEW |
---|---|
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 Loading... | |
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 ExtensionStatusMapCallback& 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 Loading... | |
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 ExtensionStatusMapCallback& callback, | |
581 scoped_ptr<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(), | |
590 callback, | |
591 base::Passed(status_map.Pass()))); | |
tzik
2014/05/22 05:14:13
s/status_map.Pass()/&status_map/
peria
2014/05/22 06:11:44
Done.
| |
592 } | |
593 | |
594 void SyncFileSystemService::DidGetV2ExtensionStatusMap( | |
595 const ExtensionStatusMapCallback& callback, | |
596 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map_v1, | |
597 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map_v2) { | |
598 // Merge |status_map_v2| into |status_map_v1|. | |
599 status_map_v1->insert(status_map_v2->begin(), status_map_v2->end()); | |
600 | |
601 callback.Run(*status_map_v1); | |
602 } | |
603 | |
581 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) { | 604 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) { |
582 sync_enabled_ = enabled; | 605 sync_enabled_ = enabled; |
583 remote_service_->SetSyncEnabled(sync_enabled_); | 606 remote_service_->SetSyncEnabled(sync_enabled_); |
584 if (v2_remote_service_) | 607 if (v2_remote_service_) |
585 v2_remote_service_->SetSyncEnabled(sync_enabled_); | 608 v2_remote_service_->SetSyncEnabled(sync_enabled_); |
586 } | 609 } |
587 | 610 |
588 void SyncFileSystemService::DidGetLocalChangeStatus( | 611 void SyncFileSystemService::DidGetLocalChangeStatus( |
589 const SyncFileStatusCallback& callback, | 612 const SyncFileStatusCallback& callback, |
590 SyncStatusCode status, | 613 SyncStatusCode status, |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
805 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get()); | 828 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get()); |
806 v2_remote_service_->SetSyncEnabled(sync_enabled_); | 829 v2_remote_service_->SetSyncEnabled(sync_enabled_); |
807 v2_remote_service_->SetDefaultConflictResolutionPolicy( | 830 v2_remote_service_->SetDefaultConflictResolutionPolicy( |
808 remote_service_->GetDefaultConflictResolutionPolicy()); | 831 remote_service_->GetDefaultConflictResolutionPolicy()); |
809 remote_sync_runners_.push_back(v2_remote_syncer.release()); | 832 remote_sync_runners_.push_back(v2_remote_syncer.release()); |
810 } | 833 } |
811 return v2_remote_service_.get(); | 834 return v2_remote_service_.get(); |
812 } | 835 } |
813 | 836 |
814 } // namespace sync_file_system | 837 } // namespace sync_file_system |
OLD | NEW |