| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_engine.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/threading/sequenced_worker_pool.h" | 8 #include "base/threading/sequenced_worker_pool.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/drive/drive_api_service.h" | 10 #include "chrome/browser/drive/drive_api_service.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 // TODO(tzik): Implement this before we support manual conflict resolution. | 210 // TODO(tzik): Implement this before we support manual conflict resolution. |
| 211 return false; | 211 return false; |
| 212 } | 212 } |
| 213 | 213 |
| 214 RemoteServiceState SyncEngine::GetCurrentState() const { | 214 RemoteServiceState SyncEngine::GetCurrentState() const { |
| 215 return service_state_; | 215 return service_state_; |
| 216 } | 216 } |
| 217 | 217 |
| 218 void SyncEngine::GetOriginStatusMap(OriginStatusMap* status_map) { | 218 void SyncEngine::GetOriginStatusMap(OriginStatusMap* status_map) { |
| 219 DCHECK(status_map); | 219 DCHECK(status_map); |
| 220 if (!extension_service_) | 220 if (!extension_service_ || !metadata_database_) |
| 221 return; | 221 return; |
| 222 | 222 |
| 223 std::vector<std::string> app_ids; | 223 std::vector<std::string> app_ids; |
| 224 metadata_database_->GetRegisteredAppIDs(&app_ids); | 224 metadata_database_->GetRegisteredAppIDs(&app_ids); |
| 225 | 225 |
| 226 for (std::vector<std::string>::const_iterator itr = app_ids.begin(); | 226 for (std::vector<std::string>::const_iterator itr = app_ids.begin(); |
| 227 itr != app_ids.end(); ++itr) { | 227 itr != app_ids.end(); ++itr) { |
| 228 const std::string& app_id = *itr; | 228 const std::string& app_id = *itr; |
| 229 GURL origin = | 229 GURL origin = |
| 230 extensions::Extension::GetBaseURLFromExtensionId(app_id); | 230 extensions::Extension::GetBaseURLFromExtensionId(app_id); |
| 231 (*status_map)[origin] = | 231 (*status_map)[origin] = |
| 232 metadata_database_->IsAppEnabled(app_id) ? "Enabled" : "Disabled"; | 232 metadata_database_->IsAppEnabled(app_id) ? "Enabled" : "Disabled"; |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 scoped_ptr<base::ListValue> SyncEngine::DumpFiles(const GURL& origin) { | 236 scoped_ptr<base::ListValue> SyncEngine::DumpFiles(const GURL& origin) { |
| 237 if (!metadata_database_) |
| 238 return scoped_ptr<base::ListValue>(); |
| 237 return metadata_database_->DumpFiles(origin.host()); | 239 return metadata_database_->DumpFiles(origin.host()); |
| 238 } | 240 } |
| 239 | 241 |
| 240 void SyncEngine::SetSyncEnabled(bool enabled) { | 242 void SyncEngine::SetSyncEnabled(bool enabled) { |
| 241 if (sync_enabled_ == enabled) | 243 if (sync_enabled_ == enabled) |
| 242 return; | 244 return; |
| 243 | 245 |
| 244 RemoteServiceState old_state = GetCurrentState(); | 246 RemoteServiceState old_state = GetCurrentState(); |
| 245 sync_enabled_ = enabled; | 247 sync_enabled_ = enabled; |
| 246 if (old_state == GetCurrentState()) | 248 if (old_state == GetCurrentState()) |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT; | 588 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT; |
| 587 if (is_app_enabled && !is_app_root_tracker_enabled) | 589 if (is_app_enabled && !is_app_root_tracker_enabled) |
| 588 EnableOrigin(origin, base::Bind(&EmptyStatusCallback)); | 590 EnableOrigin(origin, base::Bind(&EmptyStatusCallback)); |
| 589 else if (!is_app_enabled && is_app_root_tracker_enabled) | 591 else if (!is_app_enabled && is_app_root_tracker_enabled) |
| 590 DisableOrigin(origin, base::Bind(&EmptyStatusCallback)); | 592 DisableOrigin(origin, base::Bind(&EmptyStatusCallback)); |
| 591 } | 593 } |
| 592 } | 594 } |
| 593 | 595 |
| 594 } // namespace drive_backend | 596 } // namespace drive_backend |
| 595 } // namespace sync_file_system | 597 } // namespace sync_file_system |
| OLD | NEW |