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

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: Change where extension settings are saved, update TODO, api test Created 9 years, 6 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/memory/scoped_ptr.h"
10 #include "chrome/browser/extensions/extension_settings_storage.h"
11
12 // Wraps a storage area with a cache. Ownership of the delegate storage
13 // will be taken by the cache.
14 //
15 // Calls to Get() will return from the cache if an entry is present, or be
16 // passed to the delegate and the result cached if not.
17 //
18 // Calls to Set() / Clear() / Remove() are written through to the delegate,
19 // then stored in the cache if successful.
20 class ExtensionSettingsStorageCache : public ExtensionSettingsStorage {
21 public:
22 // Creates a cache around a delegate. Ownership of the delegate is taken.
23 explicit ExtensionSettingsStorageCache(ExtensionSettingsStorage* delegate);
24 ~ExtensionSettingsStorageCache() {}
25
26 int type() { return delegate_->type() | CACHED; }
27
28 void Get(const std::string& key, Callback* callback);
29 void Get(const ListValue& keys, Callback* callback);
30 void Get(Callback* callback);
31 void Set(const std::string& key, const Value& value, Callback* callback);
32 void Set(const DictionaryValue& values, Callback* callback);
33 void Remove(const std::string& key, Callback* callback);
34 void Remove(const ListValue& keys, Callback* callback);
35 void Clear(Callback *callback);
36
37 private:
38 // Returns whether the value was found in the cache.
39 // Ownership of value is released to the caller and placed in value.
40 bool GetFromCache(const std::string& key, Value** value);
41
42 scoped_ptr<ExtensionSettingsStorage> delegate_;
43 DictionaryValue cache_;
44 };
45
46 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_STORAGE_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698