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