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_AUTOMATION_PROXY_H_ | 5 #ifndef CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ |
6 #define CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ | 6 #define CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/process_util.h" | 15 #include "base/process_util.h" |
16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
17 #include "base/threading/platform_thread.h" | 17 #include "base/threading/platform_thread.h" |
18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
19 #include "base/time.h" | 19 #include "base/time.h" |
20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/common/automation_constants.h" | 21 #include "chrome/common/automation_constants.h" |
22 #include "chrome/test/automation/automation_handle_tracker.h" | 22 #include "chrome/test/automation/automation_handle_tracker.h" |
23 #include "chrome/test/automation/browser_proxy.h" | 23 #include "chrome/test/automation/browser_proxy.h" |
24 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" |
25 #include "ipc/ipc_channel_proxy.h" | 25 #include "ipc/ipc_channel_proxy.h" |
26 #include "ipc/ipc_message.h" | 26 #include "ipc/ipc_sender.h" |
27 #include "ipc/ipc_sync_channel.h" | 27 #include "ipc/ipc_sync_channel.h" |
28 #include "ui/base/ui_base_types.h" | 28 #include "ui/base/ui_base_types.h" |
29 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
30 | 30 |
31 class BrowserProxy; | 31 class BrowserProxy; |
32 class TabProxy; | 32 class TabProxy; |
33 class WindowProxy; | 33 class WindowProxy; |
34 struct ExternalTabSettings; | 34 struct ExternalTabSettings; |
35 | 35 |
36 // This is an interface that AutomationProxy-related objects can use to | 36 // This is an interface that AutomationProxy-related objects can use to |
37 // access the message-sending abilities of the Proxy. | 37 // access the message-sending abilities of the Proxy. |
38 class AutomationMessageSender : public IPC::Message::Sender { | 38 class AutomationMessageSender : public IPC::Sender { |
39 public: | 39 public: |
40 // Sends a message synchronously; it doesn't return until a response has been | 40 // Sends a message synchronously; it doesn't return until a response has been |
41 // received or a timeout has expired. | 41 // received or a timeout has expired. |
42 // | 42 // |
43 // The function returns true if a response is received, and returns false if | 43 // The function returns true if a response is received, and returns false if |
44 // there is a failure or timeout (in milliseconds). | 44 // there is a failure or timeout (in milliseconds). |
45 // | 45 // |
46 // NOTE: When timeout occurs, the connection between proxy provider may be | 46 // NOTE: When timeout occurs, the connection between proxy provider may be |
47 // in transit state. Specifically, there might be pending IPC messages, | 47 // in transit state. Specifically, there might be pending IPC messages, |
48 // and the proxy provider might be still working on the previous | 48 // and the proxy provider might be still working on the previous |
49 // request. | 49 // request. |
50 virtual bool Send(IPC::Message* message) = 0; | 50 virtual bool Send(IPC::Message* message) = 0; |
51 virtual bool Send(IPC::Message* message, int timeout_ms) = 0; | 51 virtual bool Send(IPC::Message* message, int timeout_ms) = 0; |
52 }; | 52 }; |
53 | 53 |
54 // This is the interface that external processes can use to interact with | 54 // This is the interface that external processes can use to interact with |
55 // a running instance of the app. | 55 // a running instance of the app. |
56 class AutomationProxy : public IPC::Channel::Listener, | 56 class AutomationProxy : public IPC::Listener, public AutomationMessageSender { |
57 public AutomationMessageSender { | |
58 public: | 57 public: |
59 AutomationProxy(int action_timeout_ms, bool disconnect_on_failure); | 58 AutomationProxy(int action_timeout_ms, bool disconnect_on_failure); |
60 virtual ~AutomationProxy(); | 59 virtual ~AutomationProxy(); |
61 | 60 |
62 // Creates a previously unused channel id. | 61 // Creates a previously unused channel id. |
63 static std::string GenerateChannelID(); | 62 static std::string GenerateChannelID(); |
64 | 63 |
65 // Initializes a channel for a connection to an AutomationProvider. | 64 // Initializes a channel for a connection to an AutomationProvider. |
66 // If use_named_interface is false, it will act as a client | 65 // If use_named_interface is false, it will act as a client |
67 // and connect to the named IPC socket with channel_id as its path. | 66 // and connect to the named IPC socket with channel_id as its path. |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 268 |
270 // Delay to let the browser execute the command. | 269 // Delay to let the browser execute the command. |
271 base::TimeDelta action_timeout_; | 270 base::TimeDelta action_timeout_; |
272 | 271 |
273 base::PlatformThreadId listener_thread_id_; | 272 base::PlatformThreadId listener_thread_id_; |
274 | 273 |
275 DISALLOW_COPY_AND_ASSIGN(AutomationProxy); | 274 DISALLOW_COPY_AND_ASSIGN(AutomationProxy); |
276 }; | 275 }; |
277 | 276 |
278 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ | 277 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ |
OLD | NEW |