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

Side by Side Diff: chrome/browser/extensions/settings/syncable_settings_storage.cc

Issue 8587025: Extension settings API: force through changes that come from sync (ignoring (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync 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
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/settings/syncable_settings_storage.h" 5 #include "chrome/browser/extensions/settings/syncable_settings_storage.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/extensions/settings/settings_sync_util.h" 8 #include "chrome/browser/extensions/settings/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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
43 return delegate_->Get(keys); 43 return delegate_->Get(keys);
44 } 44 }
45 45
46 SettingsStorage::ReadResult SyncableSettingsStorage::Get() { 46 SettingsStorage::ReadResult SyncableSettingsStorage::Get() {
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
48 return delegate_->Get(); 48 return delegate_->Get();
49 } 49 }
50 50
51 SettingsStorage::WriteResult SyncableSettingsStorage::Set( 51 SettingsStorage::WriteResult SyncableSettingsStorage::Set(
52 const std::string& key, const Value& value) { 52 WriteOptions options, const std::string& key, const Value& value) {
53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
54 WriteResult result = delegate_->Set(key, value); 54 WriteResult result = delegate_->Set(options, key, value);
55 if (result.HasError()) { 55 if (result.HasError()) {
56 return result; 56 return result;
57 } 57 }
58 if (sync_processor_ && !result.changes().empty()) { 58 if (sync_processor_ && !result.changes().empty()) {
59 SendChangesToSync(result.changes()); 59 SendChangesToSync(result.changes());
60 } 60 }
61 return result; 61 return result;
62 } 62 }
63 63
64 SettingsStorage::WriteResult SyncableSettingsStorage::Set( 64 SettingsStorage::WriteResult SyncableSettingsStorage::Set(
65 const DictionaryValue& values) { 65 WriteOptions options, const DictionaryValue& values) {
66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
67 WriteResult result = delegate_->Set(values); 67 WriteResult result = delegate_->Set(options, values);
68 if (result.HasError()) { 68 if (result.HasError()) {
69 return result; 69 return result;
70 } 70 }
71 if (sync_processor_ && !result.changes().empty()) { 71 if (sync_processor_ && !result.changes().empty()) {
72 SendChangesToSync(result.changes()); 72 SendChangesToSync(result.changes());
73 } 73 }
74 return result; 74 return result;
75 } 75 }
76 76
77 SettingsStorage::WriteResult SyncableSettingsStorage::Remove( 77 SettingsStorage::WriteResult SyncableSettingsStorage::Remove(
(...skipping 15 matching lines...) Expand all
93 WriteResult result = delegate_->Remove(keys); 93 WriteResult result = delegate_->Remove(keys);
94 if (result.HasError()) { 94 if (result.HasError()) {
95 return result; 95 return result;
96 } 96 }
97 if (sync_processor_ && !result.changes().empty()) { 97 if (sync_processor_ && !result.changes().empty()) {
98 SendChangesToSync(result.changes()); 98 SendChangesToSync(result.changes());
99 } 99 }
100 return result; 100 return result;
101 } 101 }
102 102
103 SettingsStorage::WriteResult 103 SettingsStorage::WriteResult SyncableSettingsStorage::Clear() {
104 SyncableSettingsStorage::Clear() {
105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
106 WriteResult result = delegate_->Clear(); 105 WriteResult result = delegate_->Clear();
107 if (result.HasError()) { 106 if (result.HasError()) {
108 return result; 107 return result;
109 } 108 }
110 if (sync_processor_ && !result.changes().empty()) { 109 if (sync_processor_ && !result.changes().empty()) {
111 SendChangesToSync(result.changes()); 110 SendChangesToSync(result.changes());
112 } 111 }
113 return result; 112 return result;
114 } 113 }
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 synced_keys_.erase(*it); 388 synced_keys_.erase(*it);
390 } 389 }
391 } 390 }
392 391
393 SyncError SyncableSettingsStorage::OnSyncAdd( 392 SyncError SyncableSettingsStorage::OnSyncAdd(
394 const std::string& key, 393 const std::string& key,
395 Value* new_value, 394 Value* new_value,
396 SettingChangeList* changes) { 395 SettingChangeList* changes) {
397 DCHECK(new_value); 396 DCHECK(new_value);
398 synced_keys_.insert(key); 397 synced_keys_.insert(key);
399 WriteResult result = delegate_->Set(key, *new_value); 398 WriteResult result = delegate_->Set(FORCE, key, *new_value);
400 if (result.HasError()) { 399 if (result.HasError()) {
401 return SyncError( 400 return SyncError(
402 FROM_HERE, 401 FROM_HERE,
403 std::string("Error pushing sync add to local settings: ") + 402 std::string("Error pushing sync add to local settings: ") +
404 result.error(), 403 result.error(),
405 sync_type_); 404 sync_type_);
406 } 405 }
407 changes->push_back(SettingChange(key, NULL, new_value)); 406 changes->push_back(SettingChange(key, NULL, new_value));
408 return SyncError(); 407 return SyncError();
409 } 408 }
410 409
411 SyncError SyncableSettingsStorage::OnSyncUpdate( 410 SyncError SyncableSettingsStorage::OnSyncUpdate(
412 const std::string& key, 411 const std::string& key,
413 Value* old_value, 412 Value* old_value,
414 Value* new_value, 413 Value* new_value,
415 SettingChangeList* changes) { 414 SettingChangeList* changes) {
416 DCHECK(old_value); 415 DCHECK(old_value);
417 DCHECK(new_value); 416 DCHECK(new_value);
418 WriteResult result = delegate_->Set(key, *new_value); 417 WriteResult result = delegate_->Set(FORCE, key, *new_value);
419 if (result.HasError()) { 418 if (result.HasError()) {
420 return SyncError( 419 return SyncError(
421 FROM_HERE, 420 FROM_HERE,
422 std::string("Error pushing sync update to local settings: ") + 421 std::string("Error pushing sync update to local settings: ") +
423 result.error(), 422 result.error(),
424 sync_type_); 423 sync_type_);
425 } 424 }
426 changes->push_back(SettingChange(key, old_value, new_value)); 425 changes->push_back(SettingChange(key, old_value, new_value));
427 return SyncError(); 426 return SyncError();
428 } 427 }
(...skipping 10 matching lines...) Expand all
439 FROM_HERE, 438 FROM_HERE,
440 std::string("Error pushing sync remove to local settings: ") + 439 std::string("Error pushing sync remove to local settings: ") +
441 result.error(), 440 result.error(),
442 sync_type_); 441 sync_type_);
443 } 442 }
444 changes->push_back(SettingChange(key, old_value, NULL)); 443 changes->push_back(SettingChange(key, old_value, NULL));
445 return SyncError(); 444 return SyncError();
446 } 445 }
447 446
448 } // namespace extensions 447 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698