Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / extensions / browser / api / storage / value_store_cache.h
blob99934424ffb005a2d76eec8c6e761d87de4c5ed2
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_API_STORAGE_VALUE_STORE_CACHE_H_
6 #define EXTENSIONS_BROWSER_API_STORAGE_VALUE_STORE_CACHE_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
13 class ValueStore;
15 namespace extensions {
17 class Extension;
19 // Each namespace of the storage API implements this interface.
20 // Instances are created on the UI thread, but from then on live on the FILE
21 // thread. At shutdown, ShutdownOnUI() is first invoked on the UI thread, and
22 // the destructor is invoked soon after on the FILE thread. This gives
23 // implementations the chance to work with ValueStores on FILE but observe
24 // events on UI.
25 // It also means that any methods invoked on UI *before ShutdownOnUI()* can
26 // safely post other methods to the FILE thread, since the deletion task is only
27 // posted to FILE after ShutdownOnUI().
28 class ValueStoreCache {
29 public:
30 typedef base::Callback<void(ValueStore*)> StorageCallback;
32 // Invoked on FILE.
33 virtual ~ValueStoreCache();
35 // This is invoked from the UI thread during destruction of the Profile that
36 // ultimately owns this object. Any Profile-related cleanups should be
37 // performed in this method, since the destructor will execute later, after
38 // the Profile is already gone.
39 virtual void ShutdownOnUI();
41 // Requests the cache to invoke |callback| with the appropriate ValueStore
42 // for the given |extension|. |callback| should be invoked with a NULL
43 // ValueStore in case of errors.
44 // |extension| is passed in a scoped_refptr<> because this method is
45 // asynchronously posted as a task to the loop returned by GetMessageLoop(),
46 // and this guarantees the Extension is still valid when the method executes.
47 virtual void RunWithValueStoreForExtension(
48 const StorageCallback& callback,
49 scoped_refptr<const Extension> extension) = 0;
51 // Requests the cache to delete any storage used by |extension_id|.
52 virtual void DeleteStorageSoon(const std::string& extension_id) = 0;
55 } // namespace extensions
57 #endif // EXTENSIONS_BROWSER_API_STORAGE_VALUE_STORE_CACHE_H_