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

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

Issue 10545128: Unrevert r141537: Add extensions::StateStore and use that instead of (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix.crash Created 8 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) 2012 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_STATE_STORE_H_
6 #define CHROME_BROWSER_EXTENSIONS_STATE_STORE_H_
7 #pragma once
8
9 #include <set>
10 #include <string>
11
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/value_store/value_store_frontend.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16
17 class Profile;
18
19 namespace extensions {
20
21 // A storage area for per-extension state that needs to be persisted to disk.
22 class StateStore
23 : public base::SupportsWeakPtr<StateStore>,
24 public content::NotificationObserver {
25 public:
26 typedef ValueStoreFrontend::ReadCallback ReadCallback;
27
28 StateStore(Profile* profile, const FilePath& db_path);
29 virtual ~StateStore();
30
31 // Register a key for removal upon extension install/uninstall. We remove
32 // for install to reset state when an extension upgrades.
33 void RegisterKey(const std::string& key);
34
35 // Get the value associated with the given extension and key, and pass
36 // it to |callback| asynchronously.
37 void GetExtensionValue(const std::string& extension_id,
38 const std::string& key,
39 ReadCallback callback);
40
41 // Sets a value for a given extension and key.
42 void SetExtensionValue(const std::string& extension_id,
43 const std::string& key,
44 scoped_ptr<base::Value> value);
45
46 private:
47 // content::NotificationObserver
48 virtual void Observe(int type,
49 const content::NotificationSource& source,
50 const content::NotificationDetails& details) OVERRIDE;
51
52 // The store that holds our key/values.
53 ValueStoreFrontend store_;
54
55 // List of all known keys. They will be cleared for each extension when it is
56 // (un)installed.
57 std::set<std::string> registered_keys_;
58
59 content::NotificationRegistrar registrar_;
60 };
61
62 } // namespace extensions
63
64 #endif // CHROME_BROWSER_EXTENSIONS_STATE_STORE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/settings/settings_sync_unittest.cc ('k') | chrome/browser/extensions/state_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698