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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 itr != v2list->end();) { | 547 itr != v2list->end();) { |
550 scoped_ptr<base::Value> item; | 548 scoped_ptr<base::Value> item; |
551 itr = v2list->Erase(itr, &item); | 549 itr = v2list->Erase(itr, &item); |
552 v1list->Append(item.release()); | 550 v1list->Append(item.release()); |
553 } | 551 } |
554 } | 552 } |
555 | 553 |
556 callback.Run(*v1list); | 554 callback.Run(*v1list); |
557 } | 555 } |
558 | 556 |
| 557 void SyncFileSystemService::DidGetExtensionStatusMap( |
| 558 const ExtensionStatusMapCallback& callback, |
| 559 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map) { |
| 560 if (!v2_remote_service_) { |
| 561 callback.Run(*status_map); |
| 562 return; |
| 563 } |
| 564 |
| 565 v2_remote_service_->GetOriginStatusMap( |
| 566 base::Bind(&SyncFileSystemService::DidGetV2ExtensionStatusMap, |
| 567 AsWeakPtr(), |
| 568 callback, |
| 569 base::Passed(&status_map))); |
| 570 } |
| 571 |
| 572 void SyncFileSystemService::DidGetV2ExtensionStatusMap( |
| 573 const ExtensionStatusMapCallback& callback, |
| 574 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map_v1, |
| 575 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map_v2) { |
| 576 // Merge |status_map_v2| into |status_map_v1|. |
| 577 status_map_v1->insert(status_map_v2->begin(), status_map_v2->end()); |
| 578 |
| 579 callback.Run(*status_map_v1); |
| 580 } |
| 581 |
559 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) { | 582 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) { |
560 sync_enabled_ = enabled; | 583 sync_enabled_ = enabled; |
561 remote_service_->SetSyncEnabled(sync_enabled_); | 584 remote_service_->SetSyncEnabled(sync_enabled_); |
562 if (v2_remote_service_) | 585 if (v2_remote_service_) |
563 v2_remote_service_->SetSyncEnabled(sync_enabled_); | 586 v2_remote_service_->SetSyncEnabled(sync_enabled_); |
564 } | 587 } |
565 | 588 |
566 void SyncFileSystemService::DidGetLocalChangeStatus( | 589 void SyncFileSystemService::DidGetLocalChangeStatus( |
567 const SyncFileStatusCallback& callback, | 590 const SyncFileStatusCallback& callback, |
568 SyncStatusCode status, | 591 SyncStatusCode status, |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 v2_remote_service_->AddServiceObserver(v2_remote_syncer.get()); | 804 v2_remote_service_->AddServiceObserver(v2_remote_syncer.get()); |
782 v2_remote_service_->AddFileStatusObserver(this); | 805 v2_remote_service_->AddFileStatusObserver(this); |
783 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get()); | 806 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get()); |
784 v2_remote_service_->SetSyncEnabled(sync_enabled_); | 807 v2_remote_service_->SetSyncEnabled(sync_enabled_); |
785 remote_sync_runners_.push_back(v2_remote_syncer.release()); | 808 remote_sync_runners_.push_back(v2_remote_syncer.release()); |
786 } | 809 } |
787 return v2_remote_service_.get(); | 810 return v2_remote_service_.get(); |
788 } | 811 } |
789 | 812 |
790 } // namespace sync_file_system | 813 } // namespace sync_file_system |
OLD | NEW |