| 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 // Returns true on success. | 68 virtual void InitializeConnection(const LaunchState& state, |
| 69 virtual bool InitializeConnection( | 69 bool wait_for_initial_loads) = 0; |
| 70 const LaunchState& state, | |
| 71 bool wait_for_initial_loads) WARN_UNUSED_RESULT = 0; | |
| 72 | 70 |
| 73 // Shuts down the browser if needed and destroys any | 71 // Shuts down the browser if needed and destroys any |
| 74 // connections established by InitalizeConnection. | 72 // connections established by InitalizeConnection. |
| 75 virtual void TerminateConnection() = 0; | 73 virtual void TerminateConnection() = 0; |
| 76 | 74 |
| 77 // Launches the browser and IPC testing connection in server mode. | 75 // Launches the browser and IPC testing connection in server mode. |
| 78 // Returns true on success. | 76 // Returns true on success. |
| 79 bool LaunchBrowserAndServer(const LaunchState& state, | 77 bool LaunchBrowserAndServer(const LaunchState& state, |
| 80 bool wait_for_initial_loads) WARN_UNUSED_RESULT; | 78 bool wait_for_initial_loads) WARN_UNUSED_RESULT; |
| 81 | 79 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // to a browser process that is already running. | 281 // to a browser process that is already running. |
| 284 // The channel id of the proxy is a constant specified by kInterfacePath. | 282 // The channel id of the proxy is a constant specified by kInterfacePath. |
| 285 class NamedProxyLauncher : public ProxyLauncher { | 283 class NamedProxyLauncher : public ProxyLauncher { |
| 286 public: | 284 public: |
| 287 // If launch_browser is true, launches Chrome with named interface enabled. | 285 // If launch_browser is true, launches Chrome with named interface enabled. |
| 288 // Otherwise, there should be an existing instance the proxy can connect to. | 286 // Otherwise, there should be an existing instance the proxy can connect to. |
| 289 NamedProxyLauncher(const std::string& channel_id, | 287 NamedProxyLauncher(const std::string& channel_id, |
| 290 bool launch_browser, bool disconnect_on_failure); | 288 bool launch_browser, bool disconnect_on_failure); |
| 291 | 289 |
| 292 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); | 290 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); |
| 293 virtual bool InitializeConnection( | 291 virtual void InitializeConnection(const LaunchState& state, |
| 294 const LaunchState& state, | 292 bool wait_for_initial_loads); |
| 295 bool wait_for_initial_loads) OVERRIDE WARN_UNUSED_RESULT; | |
| 296 virtual void TerminateConnection(); | 293 virtual void TerminateConnection(); |
| 297 virtual std::string PrefixedChannelID() const; | 294 virtual std::string PrefixedChannelID() const; |
| 298 | 295 |
| 299 protected: | 296 protected: |
| 300 std::string channel_id_; // Channel id of automation proxy. | 297 std::string channel_id_; // Channel id of automation proxy. |
| 301 bool launch_browser_; // True if we should launch the browser too. | 298 bool launch_browser_; // True if we should launch the browser too. |
| 302 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure. | 299 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure. |
| 303 | 300 |
| 304 private: | 301 private: |
| 305 DISALLOW_COPY_AND_ASSIGN(NamedProxyLauncher); | 302 DISALLOW_COPY_AND_ASSIGN(NamedProxyLauncher); |
| 306 }; | 303 }; |
| 307 | 304 |
| 308 // Uses an automation proxy that communicates over an anonymous socket. | 305 // Uses an automation proxy that communicates over an anonymous socket. |
| 309 class AnonymousProxyLauncher : public ProxyLauncher { | 306 class AnonymousProxyLauncher : public ProxyLauncher { |
| 310 public: | 307 public: |
| 311 explicit AnonymousProxyLauncher(bool disconnect_on_failure); | 308 explicit AnonymousProxyLauncher(bool disconnect_on_failure); |
| 312 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); | 309 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); |
| 313 virtual bool InitializeConnection( | 310 virtual void InitializeConnection(const LaunchState& state, |
| 314 const LaunchState& state, | 311 bool wait_for_initial_loads); |
| 315 bool wait_for_initial_loads) OVERRIDE WARN_UNUSED_RESULT; | |
| 316 virtual void TerminateConnection(); | 312 virtual void TerminateConnection(); |
| 317 virtual std::string PrefixedChannelID() const; | 313 virtual std::string PrefixedChannelID() const; |
| 318 | 314 |
| 319 protected: | 315 protected: |
| 320 std::string channel_id_; // Channel id of automation proxy. | 316 std::string channel_id_; // Channel id of automation proxy. |
| 321 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure. | 317 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure. |
| 322 | 318 |
| 323 private: | 319 private: |
| 324 DISALLOW_COPY_AND_ASSIGN(AnonymousProxyLauncher); | 320 DISALLOW_COPY_AND_ASSIGN(AnonymousProxyLauncher); |
| 325 }; | 321 }; |
| 326 | 322 |
| 327 #endif // CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ | 323 #endif // CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ |
| OLD | NEW |