OLD | NEW |
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" | |
15 #include "chrome/browser/extensions/api/storage/sync_or_local_value_store_cache.
h" | 14 #include "chrome/browser/extensions/api/storage/sync_or_local_value_store_cache.
h" |
16 #include "chrome/browser/extensions/event_names.h" | 15 #include "chrome/browser/extensions/event_names.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/extensions/api/storage.h" | 18 #include "chrome/common/extensions/api/storage.h" |
20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
21 #include "extensions/browser/event_router.h" | 20 #include "extensions/browser/event_router.h" |
22 #include "extensions/browser/extension_system.h" | 21 #include "extensions/browser/extension_system.h" |
23 | 22 |
24 #if defined(ENABLE_CONFIGURATION_POLICY) | 23 #if defined(ENABLE_CONFIGURATION_POLICY) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } | 138 } |
140 } | 139 } |
141 | 140 |
142 syncer::SyncableService* SettingsFrontend::GetBackendForSync( | 141 syncer::SyncableService* SettingsFrontend::GetBackendForSync( |
143 syncer::ModelType type) const { | 142 syncer::ModelType type) const { |
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
145 CacheMap::const_iterator it = caches_.find(settings_namespace::SYNC); | 144 CacheMap::const_iterator it = caches_.find(settings_namespace::SYNC); |
146 DCHECK(it != caches_.end()); | 145 DCHECK(it != caches_.end()); |
147 const SyncOrLocalValueStoreCache* sync_cache = | 146 const SyncOrLocalValueStoreCache* sync_cache = |
148 static_cast<const SyncOrLocalValueStoreCache*>(it->second); | 147 static_cast<const SyncOrLocalValueStoreCache*>(it->second); |
149 switch (type) { | 148 DCHECK(type == syncer::APP_SETTINGS || type == syncer::EXTENSION_SETTINGS); |
150 case syncer::APP_SETTINGS: | 149 return sync_cache->GetSyncableService(type); |
151 return sync_cache->GetAppBackend(); | |
152 case syncer::EXTENSION_SETTINGS: | |
153 return sync_cache->GetExtensionBackend(); | |
154 default: | |
155 NOTREACHED(); | |
156 return NULL; | |
157 } | |
158 } | 150 } |
159 | 151 |
160 bool SettingsFrontend::IsStorageEnabled( | 152 bool SettingsFrontend::IsStorageEnabled( |
161 settings_namespace::Namespace settings_namespace) const { | 153 settings_namespace::Namespace settings_namespace) const { |
162 return caches_.find(settings_namespace) != caches_.end(); | 154 return caches_.find(settings_namespace) != caches_.end(); |
163 } | 155 } |
164 | 156 |
165 void SettingsFrontend::RunWithStorage( | 157 void SettingsFrontend::RunWithStorage( |
166 const std::string& extension_id, | 158 const std::string& extension_id, |
167 settings_namespace::Namespace settings_namespace, | 159 settings_namespace::Namespace settings_namespace, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 CacheMap::iterator it = caches_.find(settings_namespace); | 201 CacheMap::iterator it = caches_.find(settings_namespace); |
210 if (it != caches_.end()) { | 202 if (it != caches_.end()) { |
211 ValueStoreCache* cache = it->second; | 203 ValueStoreCache* cache = it->second; |
212 cache->ShutdownOnUI(); | 204 cache->ShutdownOnUI(); |
213 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, cache); | 205 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, cache); |
214 caches_.erase(it); | 206 caches_.erase(it); |
215 } | 207 } |
216 } | 208 } |
217 | 209 |
218 } // namespace extensions | 210 } // namespace extensions |
OLD | NEW |