OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 }; | 54 }; |
55 | 55 |
56 // This is the interface that external processes can use to interact with | 56 // This is the interface that external processes can use to interact with |
57 // a running instance of the app. | 57 // a running instance of the app. |
58 class AutomationProxy : public IPC::Channel::Listener, | 58 class AutomationProxy : public IPC::Channel::Listener, |
59 public AutomationMessageSender { | 59 public AutomationMessageSender { |
60 public: | 60 public: |
61 AutomationProxy(int command_execution_timeout_ms, bool disconnect_on_failure); | 61 AutomationProxy(int command_execution_timeout_ms, bool disconnect_on_failure); |
62 virtual ~AutomationProxy(); | 62 virtual ~AutomationProxy(); |
63 | 63 |
| 64 // Creates a previously unused channel id. |
| 65 static std::string GenerateChannelID(); |
| 66 |
| 67 // Initializes a channel for a connection to an AutomationProvider. |
| 68 // If use_named_interface is false, it will act as a client |
| 69 // and connect to the named IPC socket with channel_id as its path. |
| 70 // If use_named_interface is true, it will act as a server and |
| 71 // use an anonymous socketpair instead. |
| 72 void InitializeChannel(const std::string& channel_id, |
| 73 bool use_named_interface); |
| 74 |
64 // IPC callback | 75 // IPC callback |
65 virtual void OnMessageReceived(const IPC::Message& msg); | 76 virtual void OnMessageReceived(const IPC::Message& msg); |
66 virtual void OnChannelError(); | 77 virtual void OnChannelError(); |
67 | 78 |
68 // Close the automation IPC channel. | 79 // Close the automation IPC channel. |
69 void Disconnect(); | 80 void Disconnect(); |
70 | 81 |
71 // Waits for the app to launch and the automation provider to say hello | 82 // Waits for the app to launch and the automation provider to say hello |
72 // (the app isn't fully done loading by this point). | 83 // (the app isn't fully done loading by this point). |
73 // Returns SUCCESS if the launch is successful. | 84 // Returns SUCCESS if the launch is successful. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // Resets to the default theme. Returns true on success. | 212 // Resets to the default theme. Returns true on success. |
202 bool ResetToDefaultTheme(); | 213 bool ResetToDefaultTheme(); |
203 | 214 |
204 #if defined(OS_CHROMEOS) | 215 #if defined(OS_CHROMEOS) |
205 // Logs in through the Chrome OS login wizard with given |username| | 216 // Logs in through the Chrome OS login wizard with given |username| |
206 // and |password|. Returns true on success. | 217 // and |password|. Returns true on success. |
207 bool LoginWithUserAndPass(const std::string& username, | 218 bool LoginWithUserAndPass(const std::string& username, |
208 const std::string& password) WARN_UNUSED_RESULT; | 219 const std::string& password) WARN_UNUSED_RESULT; |
209 #endif | 220 #endif |
210 | 221 |
211 // Returns the ID of the automation IPC channel, so that it can be | |
212 // passed to the app as a launch parameter. | |
213 const std::string& channel_id() const { return channel_id_; } | |
214 | |
215 #if defined(OS_POSIX) | 222 #if defined(OS_POSIX) |
216 base::file_handle_mapping_vector fds_to_map() const; | 223 base::file_handle_mapping_vector fds_to_map() const; |
217 #endif | 224 #endif |
218 | 225 |
219 // AutomationMessageSender implementation. | 226 // AutomationMessageSender implementation. |
220 virtual bool Send(IPC::Message* message) WARN_UNUSED_RESULT; | 227 virtual bool Send(IPC::Message* message) WARN_UNUSED_RESULT; |
221 | 228 |
222 // Wrapper over AutomationHandleTracker::InvalidateHandle. Receives the | 229 // Wrapper over AutomationHandleTracker::InvalidateHandle. Receives the |
223 // message from AutomationProxy, unpacks the messages and routes that call to | 230 // message from AutomationProxy, unpacks the messages and routes that call to |
224 // the tracker. | 231 // the tracker. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 void set_perform_version_check(bool perform_version_check) { | 263 void set_perform_version_check(bool perform_version_check) { |
257 perform_version_check_ = perform_version_check; | 264 perform_version_check_ = perform_version_check; |
258 } | 265 } |
259 | 266 |
260 // These functions set and reset the IPC::Channel pointer on the tracker. | 267 // These functions set and reset the IPC::Channel pointer on the tracker. |
261 void SetChannel(IPC::Channel* channel); | 268 void SetChannel(IPC::Channel* channel); |
262 void ResetChannel(); | 269 void ResetChannel(); |
263 | 270 |
264 protected: | 271 protected: |
265 template <class T> scoped_refptr<T> ProxyObjectFromHandle(int handle); | 272 template <class T> scoped_refptr<T> ProxyObjectFromHandle(int handle); |
266 void InitializeChannelID(); | |
267 void InitializeThread(); | 273 void InitializeThread(); |
268 void InitializeChannel(); | |
269 void InitializeHandleTracker(); | 274 void InitializeHandleTracker(); |
270 | 275 |
271 std::string channel_id_; | |
272 scoped_ptr<base::Thread> thread_; | 276 scoped_ptr<base::Thread> thread_; |
273 scoped_ptr<IPC::SyncChannel> channel_; | 277 scoped_ptr<IPC::SyncChannel> channel_; |
274 scoped_ptr<AutomationHandleTracker> tracker_; | 278 scoped_ptr<AutomationHandleTracker> tracker_; |
275 | 279 |
276 base::WaitableEvent app_launched_; | 280 base::WaitableEvent app_launched_; |
277 base::WaitableEvent initial_loads_complete_; | 281 base::WaitableEvent initial_loads_complete_; |
278 base::WaitableEvent new_tab_ui_load_complete_; | 282 base::WaitableEvent new_tab_ui_load_complete_; |
279 int new_tab_ui_load_time_; | 283 int new_tab_ui_load_time_; |
280 | 284 |
281 // An event that notifies when we are shutting-down. | 285 // An event that notifies when we are shutting-down. |
(...skipping 17 matching lines...) Expand all Loading... |
299 | 303 |
300 // Delay to let the browser execute the command. | 304 // Delay to let the browser execute the command. |
301 base::TimeDelta command_execution_timeout_; | 305 base::TimeDelta command_execution_timeout_; |
302 | 306 |
303 PlatformThreadId listener_thread_id_; | 307 PlatformThreadId listener_thread_id_; |
304 | 308 |
305 DISALLOW_COPY_AND_ASSIGN(AutomationProxy); | 309 DISALLOW_COPY_AND_ASSIGN(AutomationProxy); |
306 }; | 310 }; |
307 | 311 |
308 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H__ | 312 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H__ |
OLD | NEW |