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

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

Issue 175853002: Revert of Add a Restore() method to ValueStore and make StorageAPI use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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
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_frontend.h" 5 #include "chrome/browser/extensions/api/storage/settings_frontend.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
13 #include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory .h" 13 #include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory .h"
14 #include "chrome/browser/extensions/api/storage/settings_backend.h"
14 #include "chrome/browser/extensions/api/storage/sync_or_local_value_store_cache. h" 15 #include "chrome/browser/extensions/api/storage/sync_or_local_value_store_cache. h"
15 #include "chrome/browser/extensions/event_names.h" 16 #include "chrome/browser/extensions/event_names.h"
16 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/extensions/api/storage.h" 19 #include "chrome/common/extensions/api/storage.h"
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
20 #include "extensions/browser/event_router.h" 21 #include "extensions/browser/event_router.h"
21 #include "extensions/browser/extension_system.h" 22 #include "extensions/browser/extension_system.h"
22 23
23 #if defined(ENABLE_CONFIGURATION_POLICY) 24 #if defined(ENABLE_CONFIGURATION_POLICY)
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 139 }
139 } 140 }
140 141
141 syncer::SyncableService* SettingsFrontend::GetBackendForSync( 142 syncer::SyncableService* SettingsFrontend::GetBackendForSync(
142 syncer::ModelType type) const { 143 syncer::ModelType type) const {
143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
144 CacheMap::const_iterator it = caches_.find(settings_namespace::SYNC); 145 CacheMap::const_iterator it = caches_.find(settings_namespace::SYNC);
145 DCHECK(it != caches_.end()); 146 DCHECK(it != caches_.end());
146 const SyncOrLocalValueStoreCache* sync_cache = 147 const SyncOrLocalValueStoreCache* sync_cache =
147 static_cast<const SyncOrLocalValueStoreCache*>(it->second); 148 static_cast<const SyncOrLocalValueStoreCache*>(it->second);
148 DCHECK(type == syncer::APP_SETTINGS || type == syncer::EXTENSION_SETTINGS); 149 switch (type) {
149 return sync_cache->GetSyncableService(type); 150 case syncer::APP_SETTINGS:
151 return sync_cache->GetAppBackend();
152 case syncer::EXTENSION_SETTINGS:
153 return sync_cache->GetExtensionBackend();
154 default:
155 NOTREACHED();
156 return NULL;
157 }
150 } 158 }
151 159
152 bool SettingsFrontend::IsStorageEnabled( 160 bool SettingsFrontend::IsStorageEnabled(
153 settings_namespace::Namespace settings_namespace) const { 161 settings_namespace::Namespace settings_namespace) const {
154 return caches_.find(settings_namespace) != caches_.end(); 162 return caches_.find(settings_namespace) != caches_.end();
155 } 163 }
156 164
157 void SettingsFrontend::RunWithStorage( 165 void SettingsFrontend::RunWithStorage(
158 const std::string& extension_id, 166 const std::string& extension_id,
159 settings_namespace::Namespace settings_namespace, 167 settings_namespace::Namespace settings_namespace,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 CacheMap::iterator it = caches_.find(settings_namespace); 209 CacheMap::iterator it = caches_.find(settings_namespace);
202 if (it != caches_.end()) { 210 if (it != caches_.end()) {
203 ValueStoreCache* cache = it->second; 211 ValueStoreCache* cache = it->second;
204 cache->ShutdownOnUI(); 212 cache->ShutdownOnUI();
205 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, cache); 213 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, cache);
206 caches_.erase(it); 214 caches_.erase(it);
207 } 215 }
208 } 216 }
209 217
210 } // namespace extensions 218 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698