| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/drive_backend/sync_worker.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/sync_worker.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 context_->SetRemoteChangeProcessor(remote_change_processor_on_worker); | 197 context_->SetRemoteChangeProcessor(remote_change_processor_on_worker); |
| 198 } | 198 } |
| 199 | 199 |
| 200 RemoteServiceState SyncWorker::GetCurrentState() const { | 200 RemoteServiceState SyncWorker::GetCurrentState() const { |
| 201 if (!sync_enabled_) | 201 if (!sync_enabled_) |
| 202 return REMOTE_SERVICE_DISABLED; | 202 return REMOTE_SERVICE_DISABLED; |
| 203 return service_state_; | 203 return service_state_; |
| 204 } | 204 } |
| 205 | 205 |
| 206 void SyncWorker::GetOriginStatusMap( | 206 void SyncWorker::GetOriginStatusMap( |
| 207 RemoteFileSyncService::OriginStatusMap* status_map) { | 207 const RemoteFileSyncService::StatusMapCallback& callback) { |
| 208 DCHECK(status_map); | 208 RemoteFileSyncService::OriginStatusMap status_map; |
| 209 | 209 |
| 210 if (!GetMetadataDatabase()) | 210 if (!GetMetadataDatabase()) |
| 211 return; | 211 return; |
| 212 | 212 |
| 213 std::vector<std::string> app_ids; | 213 std::vector<std::string> app_ids; |
| 214 GetMetadataDatabase()->GetRegisteredAppIDs(&app_ids); | 214 GetMetadataDatabase()->GetRegisteredAppIDs(&app_ids); |
| 215 | 215 |
| 216 for (std::vector<std::string>::const_iterator itr = app_ids.begin(); | 216 for (std::vector<std::string>::const_iterator itr = app_ids.begin(); |
| 217 itr != app_ids.end(); ++itr) { | 217 itr != app_ids.end(); ++itr) { |
| 218 const std::string& app_id = *itr; | 218 const std::string& app_id = *itr; |
| 219 GURL origin = | 219 GURL origin = extensions::Extension::GetBaseURLFromExtensionId(app_id); |
| 220 extensions::Extension::GetBaseURLFromExtensionId(app_id); | 220 status_map[origin] = GetMetadataDatabase()->IsAppEnabled(app_id) ? |
| 221 (*status_map)[origin] = | |
| 222 GetMetadataDatabase()->IsAppEnabled(app_id) ? | |
| 223 "Enabled" : "Disabled"; | 221 "Enabled" : "Disabled"; |
| 224 } | 222 } |
| 223 |
| 224 callback.Run(status_map); |
| 225 } | 225 } |
| 226 | 226 |
| 227 scoped_ptr<base::ListValue> SyncWorker::DumpFiles(const GURL& origin) { | 227 scoped_ptr<base::ListValue> SyncWorker::DumpFiles(const GURL& origin) { |
| 228 if (!GetMetadataDatabase()) | 228 if (!GetMetadataDatabase()) |
| 229 return scoped_ptr<base::ListValue>(); | 229 return scoped_ptr<base::ListValue>(); |
| 230 return GetMetadataDatabase()->DumpFiles(origin.host()); | 230 return GetMetadataDatabase()->DumpFiles(origin.host()); |
| 231 } | 231 } |
| 232 | 232 |
| 233 scoped_ptr<base::ListValue> SyncWorker::DumpDatabase() { | 233 scoped_ptr<base::ListValue> SyncWorker::DumpDatabase() { |
| 234 if (!GetMetadataDatabase()) | 234 if (!GetMetadataDatabase()) |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 "Service state changed: %d->%d: %s", | 706 "Service state changed: %d->%d: %s", |
| 707 old_state, GetCurrentState(), description.c_str()); | 707 old_state, GetCurrentState(), description.c_str()); |
| 708 | 708 |
| 709 FOR_EACH_OBSERVER( | 709 FOR_EACH_OBSERVER( |
| 710 Observer, observers_, | 710 Observer, observers_, |
| 711 UpdateServiceState(GetCurrentState(), description)); | 711 UpdateServiceState(GetCurrentState(), description)); |
| 712 } | 712 } |
| 713 | 713 |
| 714 } // namespace drive_backend | 714 } // namespace drive_backend |
| 715 } // namespace sync_file_system | 715 } // namespace sync_file_system |
| OLD | NEW |