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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/state_store.h
diff --git a/chrome/browser/extensions/state_store.h b/chrome/browser/extensions/state_store.h
new file mode 100644
index 0000000000000000000000000000000000000000..ebaf86b6824fba9e1e1a1661dbce21bc3db7bc9c
--- /dev/null
+++ b/chrome/browser/extensions/state_store.h
@@ -0,0 +1,64 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_STATE_STORE_H_
+#define CHROME_BROWSER_EXTENSIONS_STATE_STORE_H_
+#pragma once
+
+#include <set>
+#include <string>
+
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/value_store/value_store_frontend.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+class Profile;
+
+namespace extensions {
+
+// A storage area for per-extension state that needs to be persisted to disk.
+class StateStore
+ : public base::SupportsWeakPtr<StateStore>,
+ public content::NotificationObserver {
+ public:
+ typedef ValueStoreFrontend::ReadCallback ReadCallback;
+
+ StateStore(Profile* profile, const FilePath& db_path);
+ virtual ~StateStore();
+
+ // Register a key for removal upon extension install/uninstall. We remove
+ // for install to reset state when an extension upgrades.
+ void RegisterKey(const std::string& key);
+
+ // Get the value associated with the given extension and key, and pass
+ // it to |callback| asynchronously.
+ void GetExtensionValue(const std::string& extension_id,
+ const std::string& key,
+ ReadCallback callback);
+
+ // Sets a value for a given extension and key.
+ void SetExtensionValue(const std::string& extension_id,
+ const std::string& key,
+ scoped_ptr<base::Value> value);
+
+ private:
+ // content::NotificationObserver
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ // The store that holds our key/values.
+ ValueStoreFrontend store_;
+
+ // List of all known keys. They will be cleared for each extension when it is
+ // (un)installed.
+ std::set<std::string> registered_keys_;
+
+ content::NotificationRegistrar registrar_;
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_STATE_STORE_H_
« 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