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); | |
209 | |
210 if (!GetMetadataDatabase()) | 208 if (!GetMetadataDatabase()) |
211 return; | 209 return; |
212 | 210 |
213 std::vector<std::string> app_ids; | 211 std::vector<std::string> app_ids; |
214 GetMetadataDatabase()->GetRegisteredAppIDs(&app_ids); | 212 GetMetadataDatabase()->GetRegisteredAppIDs(&app_ids); |
215 | 213 |
| 214 scoped_ptr<RemoteFileSyncService::OriginStatusMap> |
| 215 status_map(new RemoteFileSyncService::OriginStatusMap); |
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); | |
221 (*status_map)[origin] = | 220 (*status_map)[origin] = |
222 GetMetadataDatabase()->IsAppEnabled(app_id) ? | 221 GetMetadataDatabase()->IsAppEnabled(app_id) ? "Enabled" : "Disabled"; |
223 "Enabled" : "Disabled"; | |
224 } | 222 } |
| 223 |
| 224 callback.Run(status_map.Pass()); |
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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 "Service state changed: %d->%d: %s", | 705 "Service state changed: %d->%d: %s", |
706 old_state, GetCurrentState(), description.c_str()); | 706 old_state, GetCurrentState(), description.c_str()); |
707 | 707 |
708 FOR_EACH_OBSERVER( | 708 FOR_EACH_OBSERVER( |
709 Observer, observers_, | 709 Observer, observers_, |
710 UpdateServiceState(GetCurrentState(), description)); | 710 UpdateServiceState(GetCurrentState(), description)); |
711 } | 711 } |
712 | 712 |
713 } // namespace drive_backend | 713 } // namespace drive_backend |
714 } // namespace sync_file_system | 714 } // namespace sync_file_system |
OLD | NEW |