Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: chrome/browser/extensions/extension_settings_api.h

Issue 8375047: Separate the syncing of extension settings and app settings into separate data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_EXTENSION_SETTINGS_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/extensions/extension_function.h" 11 #include "chrome/browser/extensions/extension_function.h"
11 #include "chrome/browser/extensions/extension_settings_backend.h" 12 #include "chrome/browser/extensions/extension_settings_backend.h"
12 #include "chrome/browser/extensions/extension_settings_storage.h" 13 #include "chrome/browser/extensions/extension_settings_storage.h"
13 14
14 // Superclass of all settings functions. 15 // Superclass of all settings functions.
15 class SettingsFunction : public AsyncExtensionFunction { 16 class SettingsFunction : public AsyncExtensionFunction {
16 protected: 17 protected:
17 virtual bool RunImpl() OVERRIDE; 18 virtual bool RunImpl() OVERRIDE;
18 19
19 // Extension settings function implementations should do their work here. 20 // Extension settings function implementations should do their work here.
20 // This runs on the FILE thread. 21 // This runs on the FILE thread.
21 // 22 //
22 // Implementations should fill in args themselves, though (like RunImpl) 23 // Implementations should fill in args themselves, though (like RunImpl)
23 // may return false to imply failure. 24 // may return false to imply failure.
24 virtual bool RunWithStorage( 25 virtual bool RunWithStorage(
25 ExtensionSettingsBackend* backend, 26 scoped_refptr<ExtensionSettingsObserverList> observers,
26 ExtensionSettingsStorage* storage) = 0; 27 ExtensionSettingsStorage* storage) = 0;
27 28
28 // Sets error_ or result_ depending on the value of a storage Result, and 29 // Sets error_ or result_ depending on the value of a storage Result, and
29 // returns whether the Result implies success (i.e. !error). 30 // returns whether the Result implies success (i.e. !error).
30 bool UseResult( 31 bool UseResult(
31 ExtensionSettingsBackend* backend, 32 scoped_refptr<ExtensionSettingsObserverList> observers,
32 const ExtensionSettingsStorage::Result& storage_result); 33 const ExtensionSettingsStorage::Result& storage_result);
33 34
34 private: 35 private:
35 // Called via PostTask from RunImpl. Calls RunWithStorage and then 36 // Called via PostTask from RunImpl. Calls RunWithStorage and then
36 // SendReponse with its success value. 37 // SendReponse with its success value.
37 void RunWithBackendOnFileThread(ExtensionSettingsBackend* backend); 38 void RunWithStorageOnFileThread(
39 scoped_refptr<ExtensionSettingsObserverList> observers,
40 ExtensionSettingsStorage* storage);
38 }; 41 };
39 42
40 class GetSettingsFunction : public SettingsFunction { 43 class GetSettingsFunction : public SettingsFunction {
41 public: 44 public:
42 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.get"); 45 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.get");
43 46
44 protected: 47 protected:
45 virtual bool RunWithStorage( 48 virtual bool RunWithStorage(
46 ExtensionSettingsBackend* backend, 49 scoped_refptr<ExtensionSettingsObserverList> observers,
47 ExtensionSettingsStorage* storage) OVERRIDE; 50 ExtensionSettingsStorage* storage) OVERRIDE;
48 }; 51 };
49 52
50 class SetSettingsFunction : public SettingsFunction { 53 class SetSettingsFunction : public SettingsFunction {
51 public: 54 public:
52 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.set"); 55 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.set");
53 56
54 protected: 57 protected:
55 virtual bool RunWithStorage( 58 virtual bool RunWithStorage(
56 ExtensionSettingsBackend* backend, 59 scoped_refptr<ExtensionSettingsObserverList> observers,
57 ExtensionSettingsStorage* storage) OVERRIDE; 60 ExtensionSettingsStorage* storage) OVERRIDE;
58 }; 61 };
59 62
60 class RemoveSettingsFunction : public SettingsFunction { 63 class RemoveSettingsFunction : public SettingsFunction {
61 public: 64 public:
62 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.remove"); 65 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.remove");
63 66
64 protected: 67 protected:
65 virtual bool RunWithStorage( 68 virtual bool RunWithStorage(
66 ExtensionSettingsBackend* backend, 69 scoped_refptr<ExtensionSettingsObserverList> observers,
67 ExtensionSettingsStorage* storage) OVERRIDE; 70 ExtensionSettingsStorage* storage) OVERRIDE;
68 }; 71 };
69 72
70 class ClearSettingsFunction : public SettingsFunction { 73 class ClearSettingsFunction : public SettingsFunction {
71 public: 74 public:
72 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.clear"); 75 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.clear");
73 76
74 protected: 77 protected:
75 virtual bool RunWithStorage( 78 virtual bool RunWithStorage(
76 ExtensionSettingsBackend* backend, 79 scoped_refptr<ExtensionSettingsObserverList> observers,
77 ExtensionSettingsStorage* storage) OVERRIDE; 80 ExtensionSettingsStorage* storage) OVERRIDE;
78 }; 81 };
79 82
80 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_ 83 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698