Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_VALUE_STORE_VALUE_STORE_FRONTEND_H_ | |
| 6 #define CHROME_BROWSER_VALUE_STORE_VALUE_STORE_FRONTEND_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/callback.h" | |
| 12 #include "base/file_path.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/memory/weak_ptr.h" | |
| 16 #include "base/threading/non_thread_safe.h" | |
| 17 #include "base/values.h" | |
| 18 | |
| 19 // A frontend for a LeveldbValueStore, for use on the UI thread. | |
| 20 class ValueStoreFrontend | |
| 21 : public base::SupportsWeakPtr<ValueStoreFrontend>, | |
| 22 public base::NonThreadSafe { | |
| 23 public: | |
| 24 typedef base::Callback<void(scoped_ptr<base::Value>)> ReadCallback; | |
| 25 | |
| 26 explicit ValueStoreFrontend(const FilePath& db_path); | |
| 27 ~ValueStoreFrontend(); | |
| 28 | |
| 29 // Retrieves a value from the database asynchronously, passing a copy to | |
| 30 // |callback| when ready. NULL is passed if no matching entry is found. | |
| 31 void Get(const std::string& key, ReadCallback callback); | |
|
not at google - send to devlin
2012/06/10 11:06:08
I think callbacks can be passed as const&
Matt Perry
2012/06/11 20:09:15
Done.
| |
| 32 | |
| 33 // Sets a value with the given key. | |
| 34 void Set(const std::string& key, scoped_ptr<base::Value> value); | |
| 35 | |
| 36 // Removes the value with the given key. | |
| 37 void Remove(const std::string& key); | |
| 38 | |
| 39 private: | |
| 40 class Backend; | |
| 41 | |
| 42 // A helper class to manage lifetime of the backing ValueStore, which lives | |
| 43 // on the FILE thread. | |
| 44 scoped_refptr<Backend> backend_; | |
| 45 | |
| 46 DISALLOW_COPY_AND_ASSIGN(ValueStoreFrontend); | |
| 47 }; | |
| 48 | |
| 49 #endif // CHROME_BROWSER_VALUE_STORE_VALUE_STORE_FRONTEND_H_ | |
| OLD | NEW |