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

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

Issue 216513002: Replace DCHECK(BrowserThread::CurrentlyOn) with DCHECK_CURRENTLY_ON in extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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/settings_sync_processor.h" 5 #include "chrome/browser/extensions/api/storage/settings_sync_processor.h"
6 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" 6 #include "chrome/browser/extensions/api/storage/settings_sync_util.h"
7 #include "content/public/browser/browser_thread.h" 7 #include "content/public/browser/browser_thread.h"
8 #include "extensions/browser/api/storage/settings_namespace.h" 8 #include "extensions/browser/api/storage/settings_namespace.h"
9 #include "sync/api/sync_change_processor.h" 9 #include "sync/api/sync_change_processor.h"
10 #include "sync/api/sync_data.h" 10 #include "sync/api/sync_data.h"
11 #include "sync/protocol/extension_setting_specifics.pb.h" 11 #include "sync/protocol/extension_setting_specifics.pb.h"
12 12
13 using content::BrowserThread; 13 using content::BrowserThread;
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 SettingsSyncProcessor::SettingsSyncProcessor( 17 SettingsSyncProcessor::SettingsSyncProcessor(
18 const std::string& extension_id, 18 const std::string& extension_id,
19 syncer::ModelType type, 19 syncer::ModelType type,
20 syncer::SyncChangeProcessor* sync_processor) 20 syncer::SyncChangeProcessor* sync_processor)
21 : extension_id_(extension_id), 21 : extension_id_(extension_id),
22 type_(type), 22 type_(type),
23 sync_processor_(sync_processor), 23 sync_processor_(sync_processor),
24 initialized_(false) { 24 initialized_(false) {
25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 25 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
26 CHECK(type == syncer::EXTENSION_SETTINGS || type == syncer::APP_SETTINGS); 26 CHECK(type == syncer::EXTENSION_SETTINGS || type == syncer::APP_SETTINGS);
27 CHECK(sync_processor); 27 CHECK(sync_processor);
28 } 28 }
29 29
30 SettingsSyncProcessor::~SettingsSyncProcessor() { 30 SettingsSyncProcessor::~SettingsSyncProcessor() {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 31 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
32 } 32 }
33 33
34 void SettingsSyncProcessor::Init(const base::DictionaryValue& initial_state) { 34 void SettingsSyncProcessor::Init(const base::DictionaryValue& initial_state) {
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 35 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
36 CHECK(!initialized_) << "Init called multiple times"; 36 CHECK(!initialized_) << "Init called multiple times";
37 37
38 for (base::DictionaryValue::Iterator i(initial_state); !i.IsAtEnd(); 38 for (base::DictionaryValue::Iterator i(initial_state); !i.IsAtEnd();
39 i.Advance()) 39 i.Advance())
40 synced_keys_.insert(i.key()); 40 synced_keys_.insert(i.key());
41 41
42 initialized_ = true; 42 initialized_ = true;
43 } 43 }
44 44
45 syncer::SyncError SettingsSyncProcessor::SendChanges( 45 syncer::SyncError SettingsSyncProcessor::SendChanges(
46 const ValueStoreChangeList& changes) { 46 const ValueStoreChangeList& changes) {
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 47 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
48 CHECK(initialized_) << "Init not called"; 48 CHECK(initialized_) << "Init not called";
49 49
50 syncer::SyncChangeList sync_changes; 50 syncer::SyncChangeList sync_changes;
51 std::set<std::string> added_keys; 51 std::set<std::string> added_keys;
52 std::set<std::string> deleted_keys; 52 std::set<std::string> deleted_keys;
53 53
54 for (ValueStoreChangeList::const_iterator i = changes.begin(); 54 for (ValueStoreChangeList::const_iterator i = changes.begin();
55 i != changes.end(); ++i) { 55 i != changes.end(); ++i) {
56 const std::string& key = i->key(); 56 const std::string& key = i->key();
57 const base::Value* value = i->new_value(); 57 const base::Value* value = i->new_value();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 synced_keys_.insert(added_keys.begin(), added_keys.end()); 89 synced_keys_.insert(added_keys.begin(), added_keys.end());
90 for (std::set<std::string>::iterator i = deleted_keys.begin(); 90 for (std::set<std::string>::iterator i = deleted_keys.begin();
91 i != deleted_keys.end(); ++i) { 91 i != deleted_keys.end(); ++i) {
92 synced_keys_.erase(*i); 92 synced_keys_.erase(*i);
93 } 93 }
94 94
95 return syncer::SyncError(); 95 return syncer::SyncError();
96 } 96 }
97 97
98 void SettingsSyncProcessor::NotifyChanges(const ValueStoreChangeList& changes) { 98 void SettingsSyncProcessor::NotifyChanges(const ValueStoreChangeList& changes) {
99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 99 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
100 CHECK(initialized_) << "Init not called"; 100 CHECK(initialized_) << "Init not called";
101 101
102 for (ValueStoreChangeList::const_iterator i = changes.begin(); 102 for (ValueStoreChangeList::const_iterator i = changes.begin();
103 i != changes.end(); ++i) { 103 i != changes.end(); ++i) {
104 if (i->new_value()) 104 if (i->new_value())
105 synced_keys_.insert(i->key()); 105 synced_keys_.insert(i->key());
106 else 106 else
107 synced_keys_.erase(i->key()); 107 synced_keys_.erase(i->key());
108 } 108 }
109 } 109 }
110 110
111 } // namespace extensions 111 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698