Chromium Code Reviews| 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/extensions/api/storage/syncable_settings_storage.h" | 5 #include "chrome/browser/extensions/api/storage/syncable_settings_storage.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/extensions/api/storage/settings_namespace.h" | 8 #include "chrome/browser/extensions/api/storage/settings_namespace.h" |
| 9 #include "chrome/browser/extensions/api/storage/settings_sync_processor.h" | 9 #include "chrome/browser/extensions/api/storage/settings_sync_processor.h" |
| 10 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" | 10 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 ValueStore::WriteResult SyncableSettingsStorage::Clear() { | 115 ValueStore::WriteResult SyncableSettingsStorage::Clear() { |
| 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 117 WriteResult result = delegate_->Clear(); | 117 WriteResult result = delegate_->Clear(); |
| 118 if (result->HasError()) { | 118 if (result->HasError()) { |
| 119 return result.Pass(); | 119 return result.Pass(); |
| 120 } | 120 } |
| 121 SyncResultIfEnabled(result); | 121 SyncResultIfEnabled(result); |
| 122 return result.Pass(); | 122 return result.Pass(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool SyncableSettingsStorage::Restore() { | |
| 126 // If we're syncing, stop - we don't want to push the deletion of any data. | |
| 127 // At next startup, when we start up the sync service, we'll get back any | |
| 128 // data which was stored intact on Sync. | |
| 129 // TODO (rdevlin.cronin): Investigate if there's a way we can trigger | |
| 130 // MergeDataAndStartSyncing() to immediately get back any data we can. | |
|
not at google - send to devlin
2014/02/19 21:25:29
(and it would be very nice to continue to sync as
Devlin
2014/02/19 23:12:28
Comment updated.
| |
| 131 StopSyncing(); | |
| 132 return delegate_->Restore(); | |
| 133 } | |
| 134 | |
| 135 bool SyncableSettingsStorage::RestoreKey(const std::string& key) { | |
| 136 // If we're syncing, stop - we don't want to push the deletion of any data. | |
| 137 // At next startup, when we start up the sync service, we'll get back any | |
| 138 // data which was stored intact on Sync. | |
| 139 // TODO (rdevlin.cronin): Investigate if there's a way we can trigger | |
| 140 // MergeDataAndStartSyncing() to immediately get back any data we can. | |
| 141 StopSyncing(); | |
| 142 return delegate_->RestoreKey(key); | |
| 143 } | |
| 144 | |
| 125 void SyncableSettingsStorage::SyncResultIfEnabled( | 145 void SyncableSettingsStorage::SyncResultIfEnabled( |
| 126 const ValueStore::WriteResult& result) { | 146 const ValueStore::WriteResult& result) { |
| 127 if (result->changes().empty()) | 147 if (result->changes().empty()) |
| 128 return; | 148 return; |
| 129 | 149 |
| 130 if (sync_processor_.get()) { | 150 if (sync_processor_.get()) { |
| 131 syncer::SyncError error = sync_processor_->SendChanges(result->changes()); | 151 syncer::SyncError error = sync_processor_->SendChanges(result->changes()); |
| 132 if (error.IsSet()) | 152 if (error.IsSet()) |
| 133 StopSyncing(); | 153 StopSyncing(); |
| 134 } else { | 154 } else { |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 syncer::SyncError::DATATYPE_ERROR, | 414 syncer::SyncError::DATATYPE_ERROR, |
| 395 base::StringPrintf("Error pushing sync remove to local settings: %s", | 415 base::StringPrintf("Error pushing sync remove to local settings: %s", |
| 396 result->error().message.c_str()), | 416 result->error().message.c_str()), |
| 397 sync_processor_->type()); | 417 sync_processor_->type()); |
| 398 } | 418 } |
| 399 changes->push_back(ValueStoreChange(key, old_value, NULL)); | 419 changes->push_back(ValueStoreChange(key, old_value, NULL)); |
| 400 return syncer::SyncError(); | 420 return syncer::SyncError(); |
| 401 } | 421 } |
| 402 | 422 |
| 403 } // namespace extensions | 423 } // namespace extensions |
| OLD | NEW |