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

Side by Side Diff: chrome/browser/extensions/extension_settings_storage_cache.h

Issue 7189029: Implement an initial extension settings API. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Make clang happy Created 9 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_STORAGE_CACHE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_STORAGE_CACHE_H_
7 #pragma once
8
9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/extensions/extension_settings_storage.h"
12
13 // Wraps a storage area with a cache. Ownership of the delegate storage
14 // will be taken by the cache.
15 //
16 // Calls to Get() will return from the cache if an entry is present, or be
17 // passed to the delegate and the result cached if not.
18 //
19 // Calls to Set() / Clear() / Remove() are written through to the delegate,
20 // then stored in the cache if successful.
21 class ExtensionSettingsStorageCache : public ExtensionSettingsStorage {
22 public:
23 // Creates a cache around a delegate. Ownership of the delegate is taken.
24 explicit ExtensionSettingsStorageCache(ExtensionSettingsStorage* delegate);
25
26 virtual void DeleteSoon() OVERRIDE;
27
28 virtual void Get(const std::string& key, Callback* callback) OVERRIDE;
29 virtual void Get(const ListValue& keys, Callback* callback) OVERRIDE;
30 virtual void Get(Callback* callback) OVERRIDE;
31 virtual void Set(
32 const std::string& key, const Value& value, Callback* callback) OVERRIDE;
33 virtual void Set(const DictionaryValue& values, Callback* callback) OVERRIDE;
34 virtual void Remove(const std::string& key, Callback* callback) OVERRIDE;
35 virtual void Remove(const ListValue& keys, Callback* callback) OVERRIDE;
36 virtual void Clear(Callback *callback) OVERRIDE;
37
38 private:
39 // Delete with DeleteSoon().
40 virtual ~ExtensionSettingsStorageCache();
41
42 // Returns whether the value was found in the cache.
43 // Ownership of value is released to the caller and placed in value.
44 bool GetFromCache(const std::string& key, Value** value);
45
46 // Deleted in DeleteSoon().
47 ExtensionSettingsStorage* delegate_;
48 DictionaryValue cache_;
49 base::WeakPtrFactory<DictionaryValue> cache_ptr_factory_;
50
51 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsStorageCache);
52 };
53
54 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_STORAGE_CACHE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_settings_storage.h ('k') | chrome/browser/extensions/extension_settings_storage_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698