OLD | NEW |
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 CONTENT_PUBLIC_TEST_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_TEST_UTILS_H_ |
6 #define CONTENT_PUBLIC_TEST_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_TEST_UTILS_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "content/public/browser/browser_child_process_observer.h" |
12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/notification_details.h" | 14 #include "content/public/browser/notification_details.h" |
14 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
15 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
16 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class Value; | 20 class Value; |
20 } | 21 } |
21 | 22 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 178 |
178 ConditionTestCallback callback_; | 179 ConditionTestCallback callback_; |
179 | 180 |
180 NotificationSource source_; | 181 NotificationSource source_; |
181 NotificationDetails details_; | 182 NotificationDetails details_; |
182 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 183 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
183 | 184 |
184 DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserver); | 185 DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserver); |
185 }; | 186 }; |
186 | 187 |
| 188 // Unit tests can use code which runs in the utility process by having it run on |
| 189 // an in-process utility thread. This eliminates having two code paths in |
| 190 // production code to deal with unit tests, and also helps with the binary |
| 191 // separation on Windows since chrome.dll doesn't need to call into Blink code |
| 192 // for some utility code to handle the single process case. |
| 193 // Include this class as a member variable in your test harness if you take |
| 194 // advantage of this functionality to ensure that the in-process utility thread |
| 195 // is torn down correctly. See http://crbug.com/316919 for more information. |
| 196 // Note: this class should be declared after the TestBrowserThreadBundle and |
| 197 // ShadowingAtExitManager (if it exists) as it will need to be run before they |
| 198 // are torn down. |
| 199 class InProcessUtilityThreadHelper : public BrowserChildProcessObserver { |
| 200 public: |
| 201 InProcessUtilityThreadHelper(); |
| 202 virtual ~InProcessUtilityThreadHelper(); |
| 203 |
| 204 private: |
| 205 virtual void BrowserChildProcessHostConnected( |
| 206 const ChildProcessData& data) OVERRIDE; |
| 207 virtual void BrowserChildProcessHostDisconnected( |
| 208 const ChildProcessData& data) OVERRIDE; |
| 209 |
| 210 int child_thread_count_; |
| 211 scoped_refptr<MessageLoopRunner> runner_; |
| 212 |
| 213 DISALLOW_COPY_AND_ASSIGN(InProcessUtilityThreadHelper); |
| 214 }; |
| 215 |
187 } // namespace content | 216 } // namespace content |
188 | 217 |
189 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_ | 218 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_ |
OLD | NEW |