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 #ifndef CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ | 5 #ifndef CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ |
6 #define CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ | 6 #define CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 // If true, the window is shown. Otherwise it is hidden. | 59 // If true, the window is shown. Otherwise it is hidden. |
60 bool show_window; | 60 bool show_window; |
61 }; | 61 }; |
62 | 62 |
63 ProxyLauncher(); | 63 ProxyLauncher(); |
64 | 64 |
65 virtual ~ProxyLauncher(); | 65 virtual ~ProxyLauncher(); |
66 | 66 |
67 // Launches the browser if needed and establishes a connection with it. | 67 // Launches the browser if needed and establishes a connection with it. |
68 virtual void InitializeConnection(const LaunchState& state, | 68 // Returns true on success. |
69 bool wait_for_initial_loads) = 0; | 69 virtual bool InitializeConnection( |
| 70 const LaunchState& state, |
| 71 bool wait_for_initial_loads) WARN_UNUSED_RESULT = 0; |
70 | 72 |
71 // Shuts down the browser if needed and destroys any | 73 // Shuts down the browser if needed and destroys any |
72 // connections established by InitalizeConnection. | 74 // connections established by InitalizeConnection. |
73 virtual void TerminateConnection() = 0; | 75 virtual void TerminateConnection() = 0; |
74 | 76 |
75 // Launches the browser and IPC testing connection in server mode. | 77 // Launches the browser and IPC testing connection in server mode. |
76 // Returns true on success. | 78 // Returns true on success. |
77 bool LaunchBrowserAndServer(const LaunchState& state, | 79 bool LaunchBrowserAndServer(const LaunchState& state, |
78 bool wait_for_initial_loads) WARN_UNUSED_RESULT; | 80 bool wait_for_initial_loads) WARN_UNUSED_RESULT; |
79 | 81 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 277 |
276 DISALLOW_COPY_AND_ASSIGN(ProxyLauncher); | 278 DISALLOW_COPY_AND_ASSIGN(ProxyLauncher); |
277 }; | 279 }; |
278 | 280 |
279 // Uses an automation proxy that communicates over a named socket. | 281 // Uses an automation proxy that communicates over a named socket. |
280 // This is used if you want to connect an AutomationProxy | 282 // This is used if you want to connect an AutomationProxy |
281 // to a browser process that is already running. | 283 // to a browser process that is already running. |
282 // The channel id of the proxy is a constant specified by kInterfacePath. | 284 // The channel id of the proxy is a constant specified by kInterfacePath. |
283 class NamedProxyLauncher : public ProxyLauncher { | 285 class NamedProxyLauncher : public ProxyLauncher { |
284 public: | 286 public: |
285 // If launch_browser is true, launches Chrome with named interface enabled. | 287 struct InitParams { |
286 // Otherwise, there should be an existing instance the proxy can connect to. | 288 // True if the browser should be launched. If false, this will connect |
| 289 // to an already started Chrome. |
| 290 bool launch_browser; |
| 291 |
| 292 // True if we should disconnect on an IPC failure. |
| 293 bool disconnect_on_failure; |
| 294 |
| 295 // True if we should wait for Chrome's server channel to be initialized |
| 296 // and listening. Only set to false if it is guaranteed the server channel |
| 297 // is already listening. |
| 298 bool wait_for_server_channel; |
| 299 }; |
| 300 |
287 NamedProxyLauncher(const std::string& channel_id, | 301 NamedProxyLauncher(const std::string& channel_id, |
288 bool launch_browser, bool disconnect_on_failure); | 302 const InitParams& params); |
289 | 303 |
290 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); | 304 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); |
291 virtual void InitializeConnection(const LaunchState& state, | 305 virtual bool InitializeConnection( |
292 bool wait_for_initial_loads); | 306 const LaunchState& state, |
| 307 bool wait_for_initial_loads) OVERRIDE WARN_UNUSED_RESULT; |
293 virtual void TerminateConnection(); | 308 virtual void TerminateConnection(); |
294 virtual std::string PrefixedChannelID() const; | 309 virtual std::string PrefixedChannelID() const; |
295 | 310 |
296 protected: | 311 protected: |
297 std::string channel_id_; // Channel id of automation proxy. | 312 std::string channel_id_; // Channel id of automation proxy. |
298 bool launch_browser_; // True if we should launch the browser too. | 313 bool launch_browser_; // True if we should launch the browser too. |
299 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure. | 314 bool disconnect_on_failure_; // True if we disconnect on channel failure. |
| 315 bool wait_for_server_channel_; // True if we should wait for server channel. |
300 | 316 |
301 private: | 317 private: |
302 DISALLOW_COPY_AND_ASSIGN(NamedProxyLauncher); | 318 DISALLOW_COPY_AND_ASSIGN(NamedProxyLauncher); |
303 }; | 319 }; |
304 | 320 |
305 // Uses an automation proxy that communicates over an anonymous socket. | 321 // Uses an automation proxy that communicates over an anonymous socket. |
306 class AnonymousProxyLauncher : public ProxyLauncher { | 322 class AnonymousProxyLauncher : public ProxyLauncher { |
307 public: | 323 public: |
308 explicit AnonymousProxyLauncher(bool disconnect_on_failure); | 324 explicit AnonymousProxyLauncher(bool disconnect_on_failure); |
309 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); | 325 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); |
310 virtual void InitializeConnection(const LaunchState& state, | 326 virtual bool InitializeConnection( |
311 bool wait_for_initial_loads); | 327 const LaunchState& state, |
| 328 bool wait_for_initial_loads) OVERRIDE WARN_UNUSED_RESULT; |
312 virtual void TerminateConnection(); | 329 virtual void TerminateConnection(); |
313 virtual std::string PrefixedChannelID() const; | 330 virtual std::string PrefixedChannelID() const; |
314 | 331 |
315 protected: | 332 protected: |
316 std::string channel_id_; // Channel id of automation proxy. | 333 std::string channel_id_; // Channel id of automation proxy. |
317 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure. | 334 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure. |
318 | 335 |
319 private: | 336 private: |
320 DISALLOW_COPY_AND_ASSIGN(AnonymousProxyLauncher); | 337 DISALLOW_COPY_AND_ASSIGN(AnonymousProxyLauncher); |
321 }; | 338 }; |
322 | 339 |
323 #endif // CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ | 340 #endif // CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ |
OLD | NEW |