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

Side by Side Diff: extensions/browser/api/test/test_api.h

Issue 2282063002: [Extensions] Convert some SyncExtensionFunctions (Closed)
Patch Set: revert Created 4 years, 3 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 EXTENSIONS_BROWSER_API_TEST_TEST_API_H_ 5 #ifndef EXTENSIONS_BROWSER_API_TEST_TEST_API_H_
6 #define EXTENSIONS_BROWSER_API_TEST_TEST_API_H_ 6 #define EXTENSIONS_BROWSER_API_TEST_TEST_API_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "extensions/browser/extension_function.h" 10 #include "extensions/browser/extension_function.h"
11 11
12 namespace base { 12 namespace base {
13 13
14 template <typename T> 14 template <typename T>
15 struct DefaultSingletonTraits; 15 struct DefaultSingletonTraits;
16 16
17 } // namespace base 17 } // namespace base
18 18
19 namespace extensions { 19 namespace extensions {
20 20
21 // A function that is only available in tests. 21 // A function that is only available in tests.
22 // Prior to running, checks that we are in a testing process. 22 // Prior to running, checks that we are in a testing process.
23 class TestExtensionFunction : public SyncExtensionFunction { 23 class TestExtensionFunction : public UIThreadExtensionFunction {
24 protected: 24 protected:
25 ~TestExtensionFunction() override; 25 ~TestExtensionFunction() override;
26 26
27 // SyncExtensionFunction: 27 // ExtensionFunction:
28 bool RunSync() override; 28 bool PreRunValidation(std::string* error) override;
29
30 virtual bool RunSafe() = 0;
31 }; 29 };
32 30
33 class TestNotifyPassFunction : public TestExtensionFunction { 31 class TestNotifyPassFunction : public TestExtensionFunction {
34 public: 32 public:
35 DECLARE_EXTENSION_FUNCTION("test.notifyPass", UNKNOWN) 33 DECLARE_EXTENSION_FUNCTION("test.notifyPass", UNKNOWN)
36 34
37 protected: 35 protected:
38 ~TestNotifyPassFunction() override; 36 ~TestNotifyPassFunction() override;
39 37
40 // TestExtensionFunction: 38 // ExtensionFunction:
41 bool RunSafe() override; 39 ResponseAction Run() override;
42 }; 40 };
43 41
44 class TestNotifyFailFunction : public TestExtensionFunction { 42 class TestNotifyFailFunction : public TestExtensionFunction {
45 public: 43 public:
46 DECLARE_EXTENSION_FUNCTION("test.notifyFail", UNKNOWN) 44 DECLARE_EXTENSION_FUNCTION("test.notifyFail", UNKNOWN)
47 45
48 protected: 46 protected:
49 ~TestNotifyFailFunction() override; 47 ~TestNotifyFailFunction() override;
50 48
51 // TestExtensionFunction: 49 // ExtensionFunction:
52 bool RunSafe() override; 50 ResponseAction Run() override;
53 }; 51 };
54 52
55 class TestLogFunction : public TestExtensionFunction { 53 class TestLogFunction : public TestExtensionFunction {
56 public: 54 public:
57 DECLARE_EXTENSION_FUNCTION("test.log", UNKNOWN) 55 DECLARE_EXTENSION_FUNCTION("test.log", UNKNOWN)
58 56
59 protected: 57 protected:
60 ~TestLogFunction() override; 58 ~TestLogFunction() override;
61 59
62 // TestExtensionFunction: 60 // ExtensionFunction:
63 bool RunSafe() override; 61 ResponseAction Run() override;
64 }; 62 };
65 63
66 class TestSendMessageFunction : public UIThreadExtensionFunction { 64 class TestSendMessageFunction : public UIThreadExtensionFunction {
67 public: 65 public:
68 TestSendMessageFunction(); 66 TestSendMessageFunction();
69 DECLARE_EXTENSION_FUNCTION("test.sendMessage", UNKNOWN) 67 DECLARE_EXTENSION_FUNCTION("test.sendMessage", UNKNOWN)
70 68
71 // Sends a reply back to the calling extension. Many extensions don't need 69 // Sends a reply back to the calling extension. Many extensions don't need
72 // a reply and will just ignore it. 70 // a reply and will just ignore it.
73 void Reply(const std::string& message); 71 void Reply(const std::string& message);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 friend struct base::DefaultSingletonTraits<TestConfigState>; 112 friend struct base::DefaultSingletonTraits<TestConfigState>;
115 TestConfigState(); 113 TestConfigState();
116 114
117 base::DictionaryValue* config_state_; 115 base::DictionaryValue* config_state_;
118 116
119 DISALLOW_COPY_AND_ASSIGN(TestConfigState); 117 DISALLOW_COPY_AND_ASSIGN(TestConfigState);
120 }; 118 };
121 119
122 ~TestGetConfigFunction() override; 120 ~TestGetConfigFunction() override;
123 121
124 // TestExtensionFunction: 122 // ExtensionFunction:
125 bool RunSafe() override; 123 ResponseAction Run() override;
126 }; 124 };
127 125
128 class TestWaitForRoundTripFunction : public TestExtensionFunction { 126 class TestWaitForRoundTripFunction : public TestExtensionFunction {
129 public: 127 public:
130 DECLARE_EXTENSION_FUNCTION("test.waitForRoundTrip", UNKNOWN) 128 DECLARE_EXTENSION_FUNCTION("test.waitForRoundTrip", UNKNOWN)
131 129
132 protected: 130 protected:
133 ~TestWaitForRoundTripFunction() override; 131 ~TestWaitForRoundTripFunction() override;
134 132
135 // TestExtensionFunction: 133 // ExtensionFunction:
136 bool RunSafe() override; 134 ResponseAction Run() override;
137 }; 135 };
138 136
139 } // namespace extensions 137 } // namespace extensions
140 138
141 #endif // EXTENSIONS_BROWSER_API_TEST_TEST_API_H_ 139 #endif // EXTENSIONS_BROWSER_API_TEST_TEST_API_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/system_display/system_display_api.cc ('k') | extensions/browser/api/test/test_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698