Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: chrome/browser/extensions/api/storage/syncable_settings_storage.cc

Issue 165223003: Add a Restore() method to ValueStore and make StorageAPI use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 StopSyncing();
not at google - send to devlin 2014/02/14 19:35:56 For this method and below: I would have thought t
Devlin 2014/02/18 23:55:22 Right now, my understanding of what will happen is
not at google - send to devlin 2014/02/19 21:25:29 Cool. This is basically the same discussion we had
Devlin 2014/02/19 23:12:28 Already done on patch set 2.
128 return delegate_->Restore();
129 }
130
131 bool SyncableSettingsStorage::RestoreKey(const std::string& key) {
132 // If we're syncing, stop - we don't want to push the deletion of any data.
133 StopSyncing();
134 return delegate_->RestoreKey(key);
135 }
136
125 void SyncableSettingsStorage::SyncResultIfEnabled( 137 void SyncableSettingsStorage::SyncResultIfEnabled(
126 const ValueStore::WriteResult& result) { 138 const ValueStore::WriteResult& result) {
127 if (result->changes().empty()) 139 if (result->changes().empty())
128 return; 140 return;
129 141
130 if (sync_processor_.get()) { 142 if (sync_processor_.get()) {
131 syncer::SyncError error = sync_processor_->SendChanges(result->changes()); 143 syncer::SyncError error = sync_processor_->SendChanges(result->changes());
132 if (error.IsSet()) 144 if (error.IsSet())
133 StopSyncing(); 145 StopSyncing();
134 } else { 146 } else {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 syncer::SyncError::DATATYPE_ERROR, 406 syncer::SyncError::DATATYPE_ERROR,
395 base::StringPrintf("Error pushing sync remove to local settings: %s", 407 base::StringPrintf("Error pushing sync remove to local settings: %s",
396 result->error().message.c_str()), 408 result->error().message.c_str()),
397 sync_processor_->type()); 409 sync_processor_->type());
398 } 410 }
399 changes->push_back(ValueStoreChange(key, old_value, NULL)); 411 changes->push_back(ValueStoreChange(key, old_value, NULL));
400 return syncer::SyncError(); 412 return syncer::SyncError();
401 } 413 }
402 414
403 } // namespace extensions 415 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698