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

Side by Side Diff: extensions/browser/api/storage/local_storage_backend.cc

Issue 189263013: Move extensions storage API implementation to src/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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/local_storage_backend.h" 5 #include "extensions/browser/api/storage/local_storage_backend.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "chrome/browser/extensions/api/storage/settings_storage_factory.h" 8 #include "extensions/browser/api/storage/settings_storage_factory.h"
9 9
10 namespace extensions { 10 namespace extensions {
11 11
12 LocalStorageBackend::LocalStorageBackend( 12 LocalStorageBackend::LocalStorageBackend(
13 const scoped_refptr<SettingsStorageFactory>& storage_factory, 13 const scoped_refptr<SettingsStorageFactory>& storage_factory,
14 const base::FilePath& base_path, 14 const base::FilePath& base_path,
15 const SettingsStorageQuotaEnforcer::Limits& quota) 15 const SettingsStorageQuotaEnforcer::Limits& quota)
16 : SettingsBackend(storage_factory, base_path, quota) {} 16 : SettingsBackend(storage_factory, base_path, quota) {}
17 17
18 LocalStorageBackend::~LocalStorageBackend() {} 18 LocalStorageBackend::~LocalStorageBackend() {}
19 19
20 ValueStore* LocalStorageBackend::GetStorage(const std::string& extension_id) { 20 ValueStore* LocalStorageBackend::GetStorage(const std::string& extension_id) {
21 StorageMap::iterator iter = storage_map_.find(extension_id); 21 StorageMap::iterator iter = storage_map_.find(extension_id);
22 if (iter != storage_map_.end()) 22 if (iter != storage_map_.end())
23 return iter->second.get(); 23 return iter->second.get();
24 24
25 linked_ptr<SettingsStorageQuotaEnforcer> storage( 25 linked_ptr<SettingsStorageQuotaEnforcer> storage(
26 CreateStorageForExtension(extension_id).release()); 26 CreateStorageForExtension(extension_id).release());
27 storage_map_[extension_id] = storage; 27 storage_map_[extension_id] = storage;
28 return storage.get(); 28 return storage.get();
29 } 29 }
30 30
31 void LocalStorageBackend::DeleteStorage(const std::string& extension_id) { 31 void LocalStorageBackend::DeleteStorage(const std::string& extension_id) {
32 // Clear settings when the extension is uninstalled. 32 // Clear settings when the extension is uninstalled.
33 storage_map_.erase(extension_id); 33 storage_map_.erase(extension_id);
34 storage_factory()->DeleteDatabaseIfExists(base_path(), extension_id); 34 storage_factory()->DeleteDatabaseIfExists(base_path(), extension_id);
35 } 35 }
36 36
37 } // namespace extensions 37 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698