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

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

Issue 9427001: Extend TwoClientExtensionSettingsSyncTest to test app settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops Created 8 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/settings/settings_backend.h" 5 #include "chrome/browser/extensions/settings/settings_backend.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 result.insert(maybe_as_ascii); 126 result.insert(maybe_as_ascii);
127 } 127 }
128 } 128 }
129 129
130 return result; 130 return result;
131 } 131 }
132 132
133 static void AddAllSyncData( 133 static void AddAllSyncData(
134 const std::string& extension_id, 134 const std::string& extension_id,
135 const DictionaryValue& src, 135 const DictionaryValue& src,
136 syncable::ModelType type,
136 SyncDataList* dst) { 137 SyncDataList* dst) {
137 for (DictionaryValue::Iterator it(src); it.HasNext(); it.Advance()) { 138 for (DictionaryValue::Iterator it(src); it.HasNext(); it.Advance()) {
138 dst->push_back( 139 dst->push_back(settings_sync_util::CreateData(
139 settings_sync_util::CreateData(extension_id, it.key(), it.value())); 140 extension_id, it.key(), it.value(), type));
140 } 141 }
141 } 142 }
142 143
143 SyncDataList SettingsBackend::GetAllSyncData( 144 SyncDataList SettingsBackend::GetAllSyncData(
144 syncable::ModelType type) const { 145 syncable::ModelType type) const {
145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
146 // Ignore the type, it's just for sanity checking; assume that whatever base 147 // Ignore the type, it's just for sanity checking; assume that whatever base
147 // path we're constructed with is correct for the sync type. 148 // path we're constructed with is correct for the sync type.
148 DCHECK(type == syncable::EXTENSION_SETTINGS || 149 DCHECK(type == syncable::EXTENSION_SETTINGS ||
149 type == syncable::APP_SETTINGS); 150 type == syncable::APP_SETTINGS);
150 151
151 // For all extensions, get all their settings. This has the effect 152 // For all extensions, get all their settings. This has the effect
152 // of bringing in the entire state of extension settings in memory; sad. 153 // of bringing in the entire state of extension settings in memory; sad.
153 SyncDataList all_sync_data; 154 SyncDataList all_sync_data;
154 std::set<std::string> known_extension_ids(GetKnownExtensionIDs()); 155 std::set<std::string> known_extension_ids(GetKnownExtensionIDs());
155 156
156 for (std::set<std::string>::const_iterator it = known_extension_ids.begin(); 157 for (std::set<std::string>::const_iterator it = known_extension_ids.begin();
157 it != known_extension_ids.end(); ++it) { 158 it != known_extension_ids.end(); ++it) {
158 SettingsStorage::ReadResult maybe_settings = GetStorage(*it)->Get(); 159 SettingsStorage::ReadResult maybe_settings = GetStorage(*it)->Get();
159 if (maybe_settings.HasError()) { 160 if (maybe_settings.HasError()) {
160 LOG(WARNING) << "Failed to get settings for " << *it << ": " << 161 LOG(WARNING) << "Failed to get settings for " << *it << ": " <<
161 maybe_settings.error(); 162 maybe_settings.error();
162 continue; 163 continue;
163 } 164 }
164 AddAllSyncData(*it, maybe_settings.settings(), &all_sync_data); 165 AddAllSyncData(*it, maybe_settings.settings(), type, &all_sync_data);
165 } 166 }
166 167
167 return all_sync_data; 168 return all_sync_data;
168 } 169 }
169 170
170 SyncError SettingsBackend::MergeDataAndStartSyncing( 171 SyncError SettingsBackend::MergeDataAndStartSyncing(
171 syncable::ModelType type, 172 syncable::ModelType type,
172 const SyncDataList& initial_sync_data, 173 const SyncDataList& initial_sync_data,
173 SyncChangeProcessor* sync_processor) { 174 SyncChangeProcessor* sync_processor) {
174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 268
268 for (StorageObjMap::iterator it = storage_objs_.begin(); 269 for (StorageObjMap::iterator it = storage_objs_.begin();
269 it != storage_objs_.end(); ++it) { 270 it != storage_objs_.end(); ++it) {
270 // Some storage areas may have already stopped syncing if they had areas 271 // Some storage areas may have already stopped syncing if they had areas
271 // and syncing was disabled, but StopSyncing is safe to call multiple times. 272 // and syncing was disabled, but StopSyncing is safe to call multiple times.
272 it->second->StopSyncing(); 273 it->second->StopSyncing();
273 } 274 }
274 } 275 }
275 276
276 } // namespace extensions 277 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698