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 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 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 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 status_map.insert(status_map_v2.begin(), status_map_v2.end()); |
| 599 |
| 600 callback.Run(status_map); |
| 601 } |
| 602 |
581 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) { | 603 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) { |
582 sync_enabled_ = enabled; | 604 sync_enabled_ = enabled; |
583 remote_service_->SetSyncEnabled(sync_enabled_); | 605 remote_service_->SetSyncEnabled(sync_enabled_); |
584 if (v2_remote_service_) | 606 if (v2_remote_service_) |
585 v2_remote_service_->SetSyncEnabled(sync_enabled_); | 607 v2_remote_service_->SetSyncEnabled(sync_enabled_); |
586 } | 608 } |
587 | 609 |
588 void SyncFileSystemService::DidGetLocalChangeStatus( | 610 void SyncFileSystemService::DidGetLocalChangeStatus( |
589 const SyncFileStatusCallback& callback, | 611 const SyncFileStatusCallback& callback, |
590 SyncStatusCode status, | 612 SyncStatusCode status, |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get()); | 827 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get()); |
806 v2_remote_service_->SetSyncEnabled(sync_enabled_); | 828 v2_remote_service_->SetSyncEnabled(sync_enabled_); |
807 v2_remote_service_->SetDefaultConflictResolutionPolicy( | 829 v2_remote_service_->SetDefaultConflictResolutionPolicy( |
808 remote_service_->GetDefaultConflictResolutionPolicy()); | 830 remote_service_->GetDefaultConflictResolutionPolicy()); |
809 remote_sync_runners_.push_back(v2_remote_syncer.release()); | 831 remote_sync_runners_.push_back(v2_remote_syncer.release()); |
810 } | 832 } |
811 return v2_remote_service_.get(); | 833 return v2_remote_service_.get(); |
812 } | 834 } |
813 | 835 |
814 } // namespace sync_file_system | 836 } // namespace sync_file_system |
OLD | NEW |