OLD | NEW |
---|---|
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 // An implementation of BrowserProcess for unit tests that fails for most | 5 // An implementation of BrowserProcess for unit tests that fails for most |
6 // services. By preventing creation of services, we reduce dependencies and | 6 // services. By preventing creation of services, we reduce dependencies and |
7 // keep the profile clean. Clients of this class must handle the NULL return | 7 // keep the profile clean. Clients of this class must handle the NULL return |
8 // value, however. | 8 // value, however. |
9 | 9 |
10 #ifndef CHROME_TEST_TESTING_BROWSER_PROCESS_H_ | 10 #ifndef CHROME_TEST_TESTING_BROWSER_PROCESS_H_ |
11 #define CHROME_TEST_TESTING_BROWSER_PROCESS_H_ | 11 #define CHROME_TEST_TESTING_BROWSER_PROCESS_H_ |
12 #pragma once | 12 #pragma once |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
19 #include "content/common/notification_service.h" | 19 #include "content/common/notification_service.h" |
20 | 20 |
21 class IOThread; | 21 class IOThread; |
22 class GoogleURLTracker; | 22 class GoogleURLTracker; |
23 class NotificationUIManager; | 23 class NotificationUIManager; |
24 class PrefService; | 24 class PrefService; |
25 class WatchDogThread; | 25 class WatchDogThread; |
26 | |
mmenke
2011/05/23 21:58:41
nit: Leave these blank lines in.
dominich
2011/05/23 22:22:55
Done.
| |
27 namespace base { | 26 namespace base { |
28 class WaitableEvent; | 27 class WaitableEvent; |
29 } | 28 } |
30 | |
31 namespace policy { | 29 namespace policy { |
32 class BrowserPolicyConnector; | 30 class BrowserPolicyConnector; |
33 } | 31 } |
34 | 32 namespace prerender { |
33 class PrerenderTracker; | |
34 } | |
35 namespace ui { | 35 namespace ui { |
36 class Clipboard; | 36 class Clipboard; |
37 } | 37 } |
38 | 38 |
39 class TestingBrowserProcess : public BrowserProcess { | 39 class TestingBrowserProcess : public BrowserProcess { |
40 public: | 40 public: |
41 TestingBrowserProcess(); | 41 TestingBrowserProcess(); |
42 virtual ~TestingBrowserProcess(); | 42 virtual ~TestingBrowserProcess(); |
43 | 43 |
44 virtual void EndSession(); | 44 virtual void EndSession(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 virtual bool plugin_finder_disabled() const; | 134 virtual bool plugin_finder_disabled() const; |
135 | 135 |
136 virtual void CheckForInspectorFiles() {} | 136 virtual void CheckForInspectorFiles() {} |
137 | 137 |
138 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 138 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
139 virtual void StartAutoupdateTimer() {} | 139 virtual void StartAutoupdateTimer() {} |
140 #endif | 140 #endif |
141 | 141 |
142 virtual ChromeNetLog* net_log(); | 142 virtual ChromeNetLog* net_log(); |
143 | 143 |
144 virtual prerender::PrerenderTracker* prerender_tracker(); | |
145 | |
144 #if defined(IPC_MESSAGE_LOG_ENABLED) | 146 #if defined(IPC_MESSAGE_LOG_ENABLED) |
145 virtual void SetIPCLoggingEnabled(bool enable) {} | 147 virtual void SetIPCLoggingEnabled(bool enable) {} |
146 #endif | 148 #endif |
147 | 149 |
148 // Set the local state for tests. Consumer is responsible for cleaning it up | 150 // Set the local state for tests. Consumer is responsible for cleaning it up |
149 // afterwards (using ScopedTestingLocalState, for example). | 151 // afterwards (using ScopedTestingLocalState, for example). |
150 void SetLocalState(PrefService* local_state); | 152 void SetLocalState(PrefService* local_state); |
151 void SetGoogleURLTracker(GoogleURLTracker* google_url_tracker); | 153 void SetGoogleURLTracker(GoogleURLTracker* google_url_tracker); |
152 void SetProfileManager(ProfileManager* profile_manager); | 154 void SetProfileManager(ProfileManager* profile_manager); |
153 | 155 |
154 private: | 156 private: |
155 NotificationService notification_service_; | 157 NotificationService notification_service_; |
156 scoped_ptr<base::WaitableEvent> shutdown_event_; | 158 scoped_ptr<base::WaitableEvent> shutdown_event_; |
157 unsigned int module_ref_count_; | 159 unsigned int module_ref_count_; |
158 scoped_ptr<ui::Clipboard> clipboard_; | 160 scoped_ptr<ui::Clipboard> clipboard_; |
159 std::string app_locale_; | 161 std::string app_locale_; |
160 | 162 |
161 // Weak pointer. | 163 // Weak pointer. |
162 PrefService* local_state_; | 164 PrefService* local_state_; |
163 scoped_ptr<policy::BrowserPolicyConnector> browser_policy_connector_; | 165 scoped_ptr<policy::BrowserPolicyConnector> browser_policy_connector_; |
164 scoped_ptr<GoogleURLTracker> google_url_tracker_; | 166 scoped_ptr<GoogleURLTracker> google_url_tracker_; |
165 scoped_ptr<ProfileManager> profile_manager_; | 167 scoped_ptr<ProfileManager> profile_manager_; |
166 scoped_ptr<NotificationUIManager> notification_ui_manager_; | 168 scoped_ptr<NotificationUIManager> notification_ui_manager_; |
167 scoped_ptr<printing::BackgroundPrintingManager> background_printing_manager_; | 169 scoped_ptr<printing::BackgroundPrintingManager> background_printing_manager_; |
170 scoped_ptr<prerender::PrerenderTracker> prerender_tracker_; | |
168 | 171 |
169 DISALLOW_COPY_AND_ASSIGN(TestingBrowserProcess); | 172 DISALLOW_COPY_AND_ASSIGN(TestingBrowserProcess); |
170 }; | 173 }; |
171 | 174 |
172 // Scoper to put a TestingBrowserProcess in |g_browser_process|. | 175 // Scoper to put a TestingBrowserProcess in |g_browser_process|. |
173 class ScopedTestingBrowserProcess { | 176 class ScopedTestingBrowserProcess { |
174 public: | 177 public: |
175 ScopedTestingBrowserProcess(); | 178 ScopedTestingBrowserProcess(); |
176 ~ScopedTestingBrowserProcess(); | 179 ~ScopedTestingBrowserProcess(); |
177 | 180 |
178 TestingBrowserProcess* get() { | 181 TestingBrowserProcess* get() { |
179 return browser_process_.get(); | 182 return browser_process_.get(); |
180 } | 183 } |
181 | 184 |
182 private: | 185 private: |
183 // TODO(phajdan.jr): Temporary, for http://crbug.com/61062. | 186 // TODO(phajdan.jr): Temporary, for http://crbug.com/61062. |
184 // After the transition is over, we should just stack-allocate it. | 187 // After the transition is over, we should just stack-allocate it. |
185 scoped_ptr<TestingBrowserProcess> browser_process_; | 188 scoped_ptr<TestingBrowserProcess> browser_process_; |
186 | 189 |
187 DISALLOW_COPY_AND_ASSIGN(ScopedTestingBrowserProcess); | 190 DISALLOW_COPY_AND_ASSIGN(ScopedTestingBrowserProcess); |
188 }; | 191 }; |
189 | 192 |
190 #endif // CHROME_TEST_TESTING_BROWSER_PROCESS_H_ | 193 #endif // CHROME_TEST_TESTING_BROWSER_PROCESS_H_ |
OLD | NEW |