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

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

Issue 10071035: RefCounted types should not have public destructors, chrome/browser/extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile fix Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_TEST_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_API_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/extensions/extension_function.h" 10 #include "chrome/browser/extensions/extension_function.h"
11 11
12 template <typename T> struct DefaultSingletonTraits; 12 template <typename T> struct DefaultSingletonTraits;
13 13
14 // A function that is only available in tests. 14 // A function that is only available in tests.
15 // Prior to running, checks that we are in an extension process. 15 // Prior to running, checks that we are in an extension process.
16 class TestExtensionFunction : public SyncExtensionFunction { 16 class TestExtensionFunction : public SyncExtensionFunction {
17 public: 17 protected:
18 virtual ~TestExtensionFunction(); 18 virtual ~TestExtensionFunction();
19 19
20 // ExtensionFunction:
20 virtual void Run() OVERRIDE; 21 virtual void Run() OVERRIDE;
21 }; 22 };
22 23
23 class ExtensionTestPassFunction : public TestExtensionFunction { 24 class ExtensionTestPassFunction : public TestExtensionFunction {
25 public:
26 DECLARE_EXTENSION_FUNCTION_NAME("test.notifyPass")
27
28 protected:
24 virtual ~ExtensionTestPassFunction(); 29 virtual ~ExtensionTestPassFunction();
30
31 // ExtensionFunction:
25 virtual bool RunImpl() OVERRIDE; 32 virtual bool RunImpl() OVERRIDE;
26 DECLARE_EXTENSION_FUNCTION_NAME("test.notifyPass")
27 }; 33 };
28 34
29 class ExtensionTestFailFunction : public TestExtensionFunction { 35 class ExtensionTestFailFunction : public TestExtensionFunction {
36 public:
37 DECLARE_EXTENSION_FUNCTION_NAME("test.notifyFail")
38
39 protected:
30 virtual ~ExtensionTestFailFunction(); 40 virtual ~ExtensionTestFailFunction();
41
42 // ExtensionFunction:
31 virtual bool RunImpl() OVERRIDE; 43 virtual bool RunImpl() OVERRIDE;
32 DECLARE_EXTENSION_FUNCTION_NAME("test.notifyFail")
33 }; 44 };
34 45
35 class ExtensionTestLogFunction : public TestExtensionFunction { 46 class ExtensionTestLogFunction : public TestExtensionFunction {
47 public:
48 DECLARE_EXTENSION_FUNCTION_NAME("test.log")
49
50 protected:
36 virtual ~ExtensionTestLogFunction(); 51 virtual ~ExtensionTestLogFunction();
52
53 // ExtensionFunction:
37 virtual bool RunImpl() OVERRIDE; 54 virtual bool RunImpl() OVERRIDE;
38 DECLARE_EXTENSION_FUNCTION_NAME("test.log")
39 }; 55 };
40 56
41 class ExtensionTestQuotaResetFunction : public TestExtensionFunction { 57 class ExtensionTestQuotaResetFunction : public TestExtensionFunction {
58 public:
59 DECLARE_EXTENSION_FUNCTION_NAME("test.resetQuota")
60
61 protected:
42 virtual ~ExtensionTestQuotaResetFunction(); 62 virtual ~ExtensionTestQuotaResetFunction();
63
64 // ExtensionFunction:
43 virtual bool RunImpl() OVERRIDE; 65 virtual bool RunImpl() OVERRIDE;
44 DECLARE_EXTENSION_FUNCTION_NAME("test.resetQuota")
45 }; 66 };
46 67
47 class ExtensionTestCreateIncognitoTabFunction : public TestExtensionFunction { 68 class ExtensionTestCreateIncognitoTabFunction : public TestExtensionFunction {
69 public:
70 DECLARE_EXTENSION_FUNCTION_NAME("test.createIncognitoTab")
71
72 protected:
48 virtual ~ExtensionTestCreateIncognitoTabFunction(); 73 virtual ~ExtensionTestCreateIncognitoTabFunction();
74
75 // ExtensionFunction:
49 virtual bool RunImpl() OVERRIDE; 76 virtual bool RunImpl() OVERRIDE;
50 DECLARE_EXTENSION_FUNCTION_NAME("test.createIncognitoTab")
51 }; 77 };
52 78
53 class ExtensionTestSendMessageFunction : public AsyncExtensionFunction { 79 class ExtensionTestSendMessageFunction : public AsyncExtensionFunction {
54 public: 80 public:
81 DECLARE_EXTENSION_FUNCTION_NAME("test.sendMessage")
82
55 // Sends a reply back to the calling extension. Many extensions don't need 83 // Sends a reply back to the calling extension. Many extensions don't need
56 // a reply and will just ignore it. 84 // a reply and will just ignore it.
57 void Reply(const std::string& message); 85 void Reply(const std::string& message);
58 86
59 private: 87 protected:
60 virtual ~ExtensionTestSendMessageFunction(); 88 virtual ~ExtensionTestSendMessageFunction();
89
90 // ExtensionFunction:
61 virtual bool RunImpl() OVERRIDE; 91 virtual bool RunImpl() OVERRIDE;
62 DECLARE_EXTENSION_FUNCTION_NAME("test.sendMessage")
63 }; 92 };
64 93
65 class ExtensionTestGetConfigFunction : public SyncExtensionFunction { 94 class ExtensionTestGetConfigFunction : public SyncExtensionFunction {
66 public: 95 public:
96 DECLARE_EXTENSION_FUNCTION_NAME("test.getConfig")
97
67 // Set the dictionary returned by chrome.test.getConfig(). 98 // Set the dictionary returned by chrome.test.getConfig().
68 // Does not take ownership of |value|. 99 // Does not take ownership of |value|.
69 static void set_test_config_state(DictionaryValue* value); 100 static void set_test_config_state(DictionaryValue* value);
70 101
71 private: 102 protected:
72 // Tests that set configuration state do so by calling 103 // Tests that set configuration state do so by calling
73 // set_test_config_state() as part of test set up, and unsetting it 104 // set_test_config_state() as part of test set up, and unsetting it
74 // during tear down. This singleton class holds a pointer to that 105 // during tear down. This singleton class holds a pointer to that
75 // state, owned by the test code. 106 // state, owned by the test code.
76 class TestConfigState { 107 class TestConfigState {
77 public: 108 public:
78 static TestConfigState* GetInstance(); 109 static TestConfigState* GetInstance();
79 110
80 void set_config_state(DictionaryValue* config_state) { 111 void set_config_state(DictionaryValue* config_state) {
81 config_state_ = config_state; 112 config_state_ = config_state;
82 } 113 }
114
83 const DictionaryValue* config_state() { 115 const DictionaryValue* config_state() {
84 return config_state_; 116 return config_state_;
85 } 117 }
118
86 private: 119 private:
87 friend struct DefaultSingletonTraits<TestConfigState>; 120 friend struct DefaultSingletonTraits<TestConfigState>;
88 TestConfigState(); 121 TestConfigState();
122
89 DictionaryValue* config_state_; 123 DictionaryValue* config_state_;
124
90 DISALLOW_COPY_AND_ASSIGN(TestConfigState); 125 DISALLOW_COPY_AND_ASSIGN(TestConfigState);
91 }; 126 };
92 127
93 virtual ~ExtensionTestGetConfigFunction(); 128 virtual ~ExtensionTestGetConfigFunction();
129
130 // ExtensionFunction:
94 virtual bool RunImpl() OVERRIDE; 131 virtual bool RunImpl() OVERRIDE;
95 DECLARE_EXTENSION_FUNCTION_NAME("test.getConfig")
96 }; 132 };
97 133
98 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_API_H_ 134 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698