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

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

Issue 8670012: Extension Settings API: move the API functions into an object SettingsNamepace, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bug / 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/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 21 matching lines...) Expand all
32 // Quota for each setting. Sync supports 5k per setting, so be a bit more 32 // Quota for each setting. Sync supports 5k per setting, so be a bit more
33 // restrictive than that. 33 // restrictive than that.
34 const size_t kQuotaPerSettingBytes = 2048; 34 const size_t kQuotaPerSettingBytes = 2048;
35 35
36 // Max number of settings per extension. Keep low for sync. 36 // Max number of settings per extension. Keep low for sync.
37 const size_t kMaxSettingKeys = 512; 37 const size_t kMaxSettingKeys = 512;
38 38
39 } // namespace 39 } // namespace
40 40
41 SettingsBackend::SettingsBackend( 41 SettingsBackend::SettingsBackend(
42 SettingsStorageFactory* storage_factory, 42 const scoped_refptr<SettingsStorageFactory>& storage_factory,
43 const FilePath& base_path, 43 const FilePath& base_path,
44 const scoped_refptr<SettingsObserverList>& observers) 44 const scoped_refptr<SettingsObserverList>& observers)
45 : storage_factory_(storage_factory), 45 : storage_factory_(storage_factory),
46 base_path_(base_path), 46 base_path_(base_path),
47 observers_(observers), 47 observers_(observers),
48 sync_type_(syncable::UNSPECIFIED), 48 sync_type_(syncable::UNSPECIFIED),
49 sync_processor_(NULL) { 49 sync_processor_(NULL) {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
51 } 51 }
52 52
53 SettingsBackend::~SettingsBackend() { 53 SettingsBackend::~SettingsBackend() {
54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
55 } 55 }
56 56
57 SettingsStorage* SettingsBackend::GetStorage( 57 SettingsStorage* SettingsBackend::GetStorage(
58 const std::string& extension_id) const { 58 const std::string& extension_id) const {
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
60 DictionaryValue empty; 60 DictionaryValue empty;
61 return GetOrCreateStorageWithSyncData(extension_id, empty); 61 return GetOrCreateStorageWithSyncData(extension_id, empty);
62 } 62 }
63 63
64 SyncableSettingsStorage* 64 SyncableSettingsStorage* SettingsBackend::GetOrCreateStorageWithSyncData(
65 SettingsBackend::GetOrCreateStorageWithSyncData(
66 const std::string& extension_id, const DictionaryValue& sync_data) const { 65 const std::string& extension_id, const DictionaryValue& sync_data) const {
67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
68 67
69 StorageObjMap::iterator maybe_storage = storage_objs_.find(extension_id); 68 StorageObjMap::iterator maybe_storage = storage_objs_.find(extension_id);
70 if (maybe_storage != storage_objs_.end()) { 69 if (maybe_storage != storage_objs_.end()) {
71 return maybe_storage->second.get(); 70 return maybe_storage->second.get();
72 } 71 }
73 72
74 SettingsStorage* storage = storage_factory_->Create(base_path_, extension_id); 73 SettingsStorage* storage = storage_factory_->Create(base_path_, extension_id);
75 if (storage) { 74 if (storage) {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 287
289 for (StorageObjMap::iterator it = storage_objs_.begin(); 288 for (StorageObjMap::iterator it = storage_objs_.begin();
290 it != storage_objs_.end(); ++it) { 289 it != storage_objs_.end(); ++it) {
291 // Some storage areas may have already stopped syncing if they had areas 290 // Some storage areas may have already stopped syncing if they had areas
292 // and syncing was disabled, but StopSyncing is safe to call multiple times. 291 // and syncing was disabled, but StopSyncing is safe to call multiple times.
293 it->second->StopSyncing(); 292 it->second->StopSyncing();
294 } 293 }
295 } 294 }
296 295
297 } // namespace extensions 296 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/settings/settings_backend.h ('k') | chrome/browser/extensions/settings/settings_frontend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698