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

Unified Diff: chrome/browser/value_store/value_store_frontend.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/value_store/value_store_frontend.h
diff --git a/chrome/browser/value_store/value_store_frontend.h b/chrome/browser/value_store/value_store_frontend.h
new file mode 100644
index 0000000000000000000000000000000000000000..f6027da3adcfa6ca7a10f05190ff81c4ac8f0c6d
--- /dev/null
+++ b/chrome/browser/value_store/value_store_frontend.h
@@ -0,0 +1,49 @@
+// 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_VALUE_STORE_VALUE_STORE_FRONTEND_H_
+#define CHROME_BROWSER_VALUE_STORE_VALUE_STORE_FRONTEND_H_
+#pragma once
+
+#include <string>
+
+#include "base/callback.h"
+#include "base/file_path.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/non_thread_safe.h"
+#include "base/values.h"
+
+// A frontend for a LeveldbValueStore, for use on the UI thread.
+class ValueStoreFrontend
+ : public base::SupportsWeakPtr<ValueStoreFrontend>,
+ public base::NonThreadSafe {
+ public:
+ typedef base::Callback<void(scoped_ptr<base::Value>)> ReadCallback;
+
+ explicit ValueStoreFrontend(const FilePath& db_path);
+ ~ValueStoreFrontend();
+
+ // Retrieves a value from the database asynchronously, passing a copy to
+ // |callback| when ready. NULL is passed if no matching entry is found.
+ void Get(const std::string& key, const ReadCallback& callback);
+
+ // Sets a value with the given key.
+ void Set(const std::string& key, scoped_ptr<base::Value> value);
+
+ // Removes the value with the given key.
+ void Remove(const std::string& key);
+
+ private:
+ class Backend;
+
+ // A helper class to manage lifetime of the backing ValueStore, which lives
+ // on the FILE thread.
+ scoped_refptr<Backend> backend_;
+
+ DISALLOW_COPY_AND_ASSIGN(ValueStoreFrontend);
+};
+
+#endif // CHROME_BROWSER_VALUE_STORE_VALUE_STORE_FRONTEND_H_
« no previous file with comments | « chrome/browser/value_store/testing_value_store_unittest.cc ('k') | chrome/browser/value_store/value_store_frontend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698