OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_EXTENSIONS_SETTINGS_VALUE_STORE_CACHE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_VALUE_STORE_CACHE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_VALUE_STORE_CACHE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_VALUE_STORE_CACHE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
13 | 13 |
14 class ValueStore; | 14 class ValueStore; |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 | 17 |
18 class Extension; | 18 class Extension; |
19 | 19 |
20 // Each namespace of the storage API implements this interface. | 20 // Each namespace of the storage API implements this interface. |
21 // Instances are created on the UI thread, but from then on live on the loop | 21 // Instances are created on the UI thread, but from then on live on the loop |
22 // returned by GetMessageLoop() and every methods (except GetMessageLoop()) | 22 // returned by GetMessageLoop() and every method (except GetMessageLoop() |
23 // are always called in that loop, including the destructor. | 23 // and ShutdownOnUI()) is always called in that loop, including the destructor. |
24 class ValueStoreCache { | 24 class ValueStoreCache { |
25 public: | 25 public: |
26 typedef base::Callback<void(ValueStore*)> StorageCallback; | 26 typedef base::Callback<void(ValueStore*)> StorageCallback; |
27 | 27 |
28 virtual ~ValueStoreCache(); | 28 virtual ~ValueStoreCache(); |
29 | 29 |
| 30 // This is invoked from the UI thread during destruction of the Profile that |
| 31 // ultimately owns this object. Any Profile-related cleanups should be |
| 32 // performed in this method, since the destructor will execute later, after |
| 33 // the Profile is already gone. |
| 34 virtual void ShutdownOnUI(); |
| 35 |
30 // Returns the loop that the methods of this class should be invoked on. | 36 // Returns the loop that the methods of this class should be invoked on. |
31 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() const = 0; | 37 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() const = 0; |
32 | 38 |
33 // Requests the cache to invoke |callback| with the appropriate ValueStore | 39 // Requests the cache to invoke |callback| with the appropriate ValueStore |
34 // for the given |extension|. |callback| should be invoked with a NULL | 40 // for the given |extension|. |callback| should be invoked with a NULL |
35 // ValueStore in case of errors. | 41 // ValueStore in case of errors. |
36 // |extension| is passed in a scoped_refptr<> because this method is | 42 // |extension| is passed in a scoped_refptr<> because this method is |
37 // asynchronously posted as a task to the loop returned by GetMessageLoop(), | 43 // asynchronously posted as a task to the loop returned by GetMessageLoop(), |
38 // and this guarantees the Extension is still valid when the method executes. | 44 // and this guarantees the Extension is still valid when the method executes. |
39 virtual void RunWithValueStoreForExtension( | 45 virtual void RunWithValueStoreForExtension( |
40 const StorageCallback& callback, | 46 const StorageCallback& callback, |
41 scoped_refptr<const Extension> extension) = 0; | 47 scoped_refptr<const Extension> extension) = 0; |
42 | 48 |
43 // Requests the cache to delete any storage used by |extension_id|. | 49 // Requests the cache to delete any storage used by |extension_id|. |
44 virtual void DeleteStorageSoon(const std::string& extension_id) = 0; | 50 virtual void DeleteStorageSoon(const std::string& extension_id) = 0; |
45 }; | 51 }; |
46 | 52 |
47 } // namespace extensions | 53 } // namespace extensions |
48 | 54 |
49 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_VALUE_STORE_CACHE_H_ | 55 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_VALUE_STORE_CACHE_H_ |
OLD | NEW |