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

Side by Side Diff: chrome/browser/extensions/syncable_extension_settings_storage.cc

Issue 8341043: Extension settings API: send ACTION_UPDATE rather than ACTION_ADD when a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_settings_sync_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/syncable_extension_settings_storage.h" 5 #include "chrome/browser/extensions/syncable_extension_settings_storage.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/extensions/extension_settings_sync_util.h" 8 #include "chrome/browser/extensions/extension_settings_sync_util.h"
9 #include "chrome/browser/sync/api/sync_data.h" 9 #include "chrome/browser/sync/api/sync_data.h"
10 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h" 10 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 scoped_ptr<DictionaryValue> new_sync_state(sync_state.DeepCopy()); 167 scoped_ptr<DictionaryValue> new_sync_state(sync_state.DeepCopy());
168 168
169 ExtensionSettingSyncDataList changes; 169 ExtensionSettingSyncDataList changes;
170 for (DictionaryValue::key_iterator it = settings.begin_keys(); 170 for (DictionaryValue::key_iterator it = settings.begin_keys();
171 it != settings.end_keys(); ++it) { 171 it != settings.end_keys(); ++it) {
172 Value* orphaned_sync_value = NULL; 172 Value* orphaned_sync_value = NULL;
173 if (new_sync_state->RemoveWithoutPathExpansion(*it, &orphaned_sync_value)) { 173 if (new_sync_state->RemoveWithoutPathExpansion(*it, &orphaned_sync_value)) {
174 scoped_ptr<Value> sync_value(orphaned_sync_value); 174 scoped_ptr<Value> sync_value(orphaned_sync_value);
175 Value* local_value = NULL; 175 Value* local_value = NULL;
176 settings.GetWithoutPathExpansion(*it, &local_value); 176 settings.GetWithoutPathExpansion(*it, &local_value);
177 if (!sync_value->Equals(local_value)) { 177 if (!sync_value->Equals(local_value)) {
akalin 2011/10/26 18:58:34 backwards test is confusing, can you rewrite as:
not at google - send to devlin 2011/10/27 01:54:39 Done.
178 // Sync value is different, update local setting with new value. 178 // Sync value is different, update local setting with new value.
179 changes.push_back( 179 changes.push_back(
180 ExtensionSettingSyncData( 180 ExtensionSettingSyncData(
181 SyncChange::ACTION_UPDATE, 181 SyncChange::ACTION_UPDATE,
182 extension_id_, 182 extension_id_,
183 *it, 183 *it,
184 sync_value.release())); 184 sync_value.release()));
185 } else {
186 // Sync and local values are the same, no changes to send.
187 synced_keys_.insert(*it);
185 } 188 }
186 } else { 189 } else {
187 // Not synced, delete local setting. 190 // Not synced, delete local setting.
188 changes.push_back( 191 changes.push_back(
189 ExtensionSettingSyncData( 192 ExtensionSettingSyncData(
190 SyncChange::ACTION_DELETE, 193 SyncChange::ACTION_DELETE,
191 extension_id_, 194 extension_id_,
192 *it, 195 *it,
193 new DictionaryValue())); 196 new DictionaryValue()));
194 } 197 }
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 if (result.HasError()) { 432 if (result.HasError()) {
430 return SyncError( 433 return SyncError(
431 FROM_HERE, 434 FROM_HERE,
432 std::string("Error pushing sync remove to local settings: ") + 435 std::string("Error pushing sync remove to local settings: ") +
433 result.GetError(), 436 result.GetError(),
434 syncable::EXTENSION_SETTINGS); 437 syncable::EXTENSION_SETTINGS);
435 } 438 }
436 changes->AppendChange(key, old_value, NULL); 439 changes->AppendChange(key, old_value, NULL);
437 return SyncError(); 440 return SyncError();
438 } 441 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_settings_sync_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698