| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FRONTEND_H_ | 5 #ifndef EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FRONTEND_H_ |
| 6 #define EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FRONTEND_H_ | 6 #define EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FRONTEND_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/threading/non_thread_safe.h" | |
| 16 #include "base/values.h" | 15 #include "base/values.h" |
| 17 #include "extensions/browser/value_store/value_store.h" | 16 #include "extensions/browser/value_store/value_store.h" |
| 18 | 17 |
| 19 namespace extensions { | 18 namespace extensions { |
| 20 class ValueStoreFactory; | 19 class ValueStoreFactory; |
| 21 } // namespace extensions | 20 } // namespace extensions |
| 22 | 21 |
| 23 // A frontend for a LeveldbValueStore, for use on the UI thread. | 22 // A frontend for a LeveldbValueStore, for use on the UI thread. |
| 24 class ValueStoreFrontend | 23 class ValueStoreFrontend : public base::SupportsWeakPtr<ValueStoreFrontend> { |
| 25 : public base::SupportsWeakPtr<ValueStoreFrontend>, | |
| 26 public base::NonThreadSafe { | |
| 27 public: | 24 public: |
| 28 // The kind of extensions data stored in a backend. | 25 // The kind of extensions data stored in a backend. |
| 29 enum class BackendType { RULES, STATE }; | 26 enum class BackendType { RULES, STATE }; |
| 30 | 27 |
| 31 typedef base::Callback<void(std::unique_ptr<base::Value>)> ReadCallback; | 28 typedef base::Callback<void(std::unique_ptr<base::Value>)> ReadCallback; |
| 32 | 29 |
| 33 ValueStoreFrontend( | 30 ValueStoreFrontend( |
| 34 const scoped_refptr<extensions::ValueStoreFactory>& store_factory, | 31 const scoped_refptr<extensions::ValueStoreFactory>& store_factory, |
| 35 BackendType backend_type); | 32 BackendType backend_type); |
| 36 ~ValueStoreFrontend(); | 33 ~ValueStoreFrontend(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 49 class Backend; | 46 class Backend; |
| 50 | 47 |
| 51 // A helper class to manage lifetime of the backing ValueStore, which lives | 48 // A helper class to manage lifetime of the backing ValueStore, which lives |
| 52 // on the FILE thread. | 49 // on the FILE thread. |
| 53 scoped_refptr<Backend> backend_; | 50 scoped_refptr<Backend> backend_; |
| 54 | 51 |
| 55 DISALLOW_COPY_AND_ASSIGN(ValueStoreFrontend); | 52 DISALLOW_COPY_AND_ASSIGN(ValueStoreFrontend); |
| 56 }; | 53 }; |
| 57 | 54 |
| 58 #endif // EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FRONTEND_H_ | 55 #endif // EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FRONTEND_H_ |
| OLD | NEW |