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

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 "chrome/browser/extensions/extension_function.h" 10 #include "chrome/browser/extensions/extension_function.h"
11 #include "chrome/browser/extensions/extension_settings_backend.h" 11 #include "chrome/browser/extensions/extension_settings_backend.h"
12 #include "chrome/browser/extensions/extension_settings_storage.h" 12 #include "chrome/browser/extensions/extension_settings_storage.h"
13 13
14 // Superclass of all settings functions. 14 // Superclass of all settings functions.
15 class SettingsFunction : public AsyncExtensionFunction { 15 class SettingsFunction : public AsyncExtensionFunction {
16 protected: 16 protected:
17 virtual bool RunImpl() OVERRIDE; 17 virtual bool RunImpl() OVERRIDE;
18 18
19 // Extension settings function implementations should do their work here. 19 // Extension settings function implementations should do their work here.
20 // This runs on the FILE thread. 20 // This runs on the FILE thread.
21 // 21 //
22 // Implementations should fill in args themselves, though (like RunImpl) 22 // Implementations should fill in args themselves, though (like RunImpl)
23 // may return false to imply failure. 23 // may return false to imply failure.
24 virtual bool RunWithStorage( 24 virtual bool RunWithStorage(
25 ExtensionSettingsBackend* backend, 25 ExtensionSettingsObserverList* observers,
26 ExtensionSettingsStorage* storage) = 0; 26 ExtensionSettingsStorage* storage) = 0;
27 27
28 // Sets error_ or result_ depending on the value of a storage Result, and 28 // Sets error_ or result_ depending on the value of a storage Result, and
29 // returns whether the Result implies success (i.e. !error). 29 // returns whether the Result implies success (i.e. !error).
30 bool UseResult( 30 bool UseResult(
31 ExtensionSettingsBackend* backend, 31 ExtensionSettingsObserverList* observers,
32 const ExtensionSettingsStorage::Result& storage_result); 32 const ExtensionSettingsStorage::Result& storage_result);
33 33
34 private: 34 private:
35 // Called via PostTask from RunImpl. Calls RunWithStorage and then 35 // Called via PostTask from RunImpl. Calls RunWithStorage and then
36 // SendReponse with its success value. 36 // SendReponse with its success value.
37 void RunWithBackendOnFileThread(ExtensionSettingsBackend* backend); 37 void RunWithStorageOnFileThread(
38 scoped_refptr<ExtensionSettingsObserverList> observers,
39 ExtensionSettingsStorage* storage);
38 }; 40 };
39 41
40 class GetSettingsFunction : public SettingsFunction { 42 class GetSettingsFunction : public SettingsFunction {
41 public: 43 public:
42 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.get"); 44 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.get");
43 45
44 protected: 46 protected:
45 virtual bool RunWithStorage( 47 virtual bool RunWithStorage(
46 ExtensionSettingsBackend* backend, 48 ExtensionSettingsObserverList* observers,
47 ExtensionSettingsStorage* storage) OVERRIDE; 49 ExtensionSettingsStorage* storage) OVERRIDE;
48 }; 50 };
49 51
50 class SetSettingsFunction : public SettingsFunction { 52 class SetSettingsFunction : public SettingsFunction {
51 public: 53 public:
52 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.set"); 54 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.set");
53 55
54 protected: 56 protected:
55 virtual bool RunWithStorage( 57 virtual bool RunWithStorage(
56 ExtensionSettingsBackend* backend, 58 ExtensionSettingsObserverList* observers,
57 ExtensionSettingsStorage* storage) OVERRIDE; 59 ExtensionSettingsStorage* storage) OVERRIDE;
58 }; 60 };
59 61
60 class RemoveSettingsFunction : public SettingsFunction { 62 class RemoveSettingsFunction : public SettingsFunction {
61 public: 63 public:
62 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.remove"); 64 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.remove");
63 65
64 protected: 66 protected:
65 virtual bool RunWithStorage( 67 virtual bool RunWithStorage(
66 ExtensionSettingsBackend* backend, 68 ExtensionSettingsObserverList* observers,
67 ExtensionSettingsStorage* storage) OVERRIDE; 69 ExtensionSettingsStorage* storage) OVERRIDE;
68 }; 70 };
69 71
70 class ClearSettingsFunction : public SettingsFunction { 72 class ClearSettingsFunction : public SettingsFunction {
71 public: 73 public:
72 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.clear"); 74 DECLARE_EXTENSION_FUNCTION_NAME("experimental.settings.clear");
73 75
74 protected: 76 protected:
75 virtual bool RunWithStorage( 77 virtual bool RunWithStorage(
76 ExtensionSettingsBackend* backend, 78 ExtensionSettingsObserverList* observers,
77 ExtensionSettingsStorage* storage) OVERRIDE; 79 ExtensionSettingsStorage* storage) OVERRIDE;
78 }; 80 };
79 81
80 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_ 82 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698