| 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_EXTENSIONS_SETTINGS_VALUE_STORE_CACHE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_VALUE_STORE_CACHE_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/message_loop_proxy.h" |
| 13 |
| 14 class ValueStore; |
| 15 |
| 16 namespace extensions { |
| 17 |
| 18 class Extension; |
| 19 |
| 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 |
| 22 // returned by GetMessageLoop() and every methods (except GetMessageLoop()) |
| 23 // are always called in that loop, including the destructor. |
| 24 class ValueStoreCache { |
| 25 public: |
| 26 typedef base::Callback<void(ValueStore*)> StorageCallback; |
| 27 |
| 28 virtual ~ValueStoreCache(); |
| 29 |
| 30 // Returns the loop that the methods of this class should be invoked on. |
| 31 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() const = 0; |
| 32 |
| 33 // Requests the cache to invoke |callback| with the appropriate ValueStore |
| 34 // for the given |extension|. |callback| should be invoked with a NULL |
| 35 // ValueStore in case of errors. |
| 36 // |extension| is passed in a scoped_refptr<> because this method is |
| 37 // asynchronously posted as a task to the loop returned by GetMessageLoop(), |
| 38 // and this guarantees the Extension is still valid when the method executes. |
| 39 virtual void RunWithValueStoreForExtension( |
| 40 const StorageCallback& callback, |
| 41 scoped_refptr<const Extension> extension) = 0; |
| 42 |
| 43 // Requests the cache to delete any storage used by |extension_id|. |
| 44 virtual void DeleteStorageSoon(const std::string& extension_id) = 0; |
| 45 }; |
| 46 |
| 47 } // namespace extensions |
| 48 |
| 49 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_VALUE_STORE_CACHE_H_ |
| OLD | NEW |