| 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 CHROME_TEST_CHROMEDRIVER_COMMANDS_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_COMMANDS_H_ |
| 6 #define CHROME_TEST_CHROMEDRIVER_COMMANDS_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_COMMANDS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/test/chromedriver/command.h" | 13 #include "chrome/test/chromedriver/command.h" |
| 14 #include "chrome/test/chromedriver/net/sync_websocket_factory.h" | 14 #include "chrome/test/chromedriver/net/sync_websocket_factory.h" |
| 15 #include "chrome/test/chromedriver/session_map.h" | 15 #include "chrome/test/chromedriver/session_thread_map.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class DictionaryValue; | 18 class DictionaryValue; |
| 19 class Value; | 19 class Value; |
| 20 } | 20 } |
| 21 | 21 |
| 22 class DeviceManager; | 22 class DeviceManager; |
| 23 class Log; | 23 class Log; |
| 24 struct Session; |
| 24 class Status; | 25 class Status; |
| 25 class URLRequestContextGetter; | 26 class URLRequestContextGetter; |
| 26 | 27 |
| 27 // Gets status/info about ChromeDriver. | 28 // Gets status/info about ChromeDriver. |
| 28 Status ExecuteGetStatus( | 29 void ExecuteGetStatus( |
| 29 const base::DictionaryValue& params, | 30 const base::DictionaryValue& params, |
| 30 const std::string& session_id, | 31 const std::string& session_id, |
| 31 scoped_ptr<base::Value>* out_value, | 32 const CommandCallback& callback); |
| 32 std::string* out_session_id); | |
| 33 | 33 |
| 34 struct NewSessionParams { | 34 struct NewSessionParams { |
| 35 NewSessionParams(Log* log, | 35 NewSessionParams(Log* log, |
| 36 SessionMap* session_map, | 36 SessionThreadMap* session_thread_map, |
| 37 scoped_refptr<URLRequestContextGetter> context_getter, | 37 scoped_refptr<URLRequestContextGetter> context_getter, |
| 38 const SyncWebSocketFactory& socket_factory, | 38 const SyncWebSocketFactory& socket_factory, |
| 39 DeviceManager* device_manager); | 39 DeviceManager* device_manager); |
| 40 ~NewSessionParams(); | 40 ~NewSessionParams(); |
| 41 | 41 |
| 42 Log* log; | 42 Log* log; |
| 43 SessionMap* session_map; | 43 SessionThreadMap* session_thread_map; |
| 44 scoped_refptr<URLRequestContextGetter> context_getter; | 44 scoped_refptr<URLRequestContextGetter> context_getter; |
| 45 SyncWebSocketFactory socket_factory; | 45 SyncWebSocketFactory socket_factory; |
| 46 DeviceManager* device_manager; | 46 DeviceManager* device_manager; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 // Creates a new session. | 49 // Creates a new session. |
| 50 Status ExecuteNewSession( | 50 void ExecuteNewSession( |
| 51 const NewSessionParams& bound_params, | 51 const NewSessionParams& bound_params, |
| 52 const base::DictionaryValue& params, | 52 const base::DictionaryValue& params, |
| 53 const std::string& session_id, | 53 const std::string& session_id, |
| 54 scoped_ptr<base::Value>* out_value, | 54 const CommandCallback& callback); |
| 55 std::string* out_session_id); | |
| 56 | 55 |
| 57 // Quits a particular session. | 56 // Quits all sessions. |
| 58 Status ExecuteQuit( | 57 void ExecuteQuitAll( |
| 59 bool allow_detach, | 58 const Command& quit_command, |
| 60 SessionMap* session_map, | 59 SessionThreadMap* session_thread_map, |
| 61 const base::DictionaryValue& params, | 60 const base::DictionaryValue& params, |
| 62 const std::string& session_id, | 61 const std::string& session_id, |
| 63 scoped_ptr<base::Value>* out_value, | 62 const CommandCallback& callback); |
| 64 std::string* out_session_id); | |
| 65 | 63 |
| 66 // Quits all sessions. | 64 typedef base::Callback<Status( |
| 67 Status ExecuteQuitAll( | 65 Session* session, |
| 68 Command quit_command, | 66 const base::DictionaryValue&, |
| 69 SessionMap* session_map, | 67 scoped_ptr<base::Value>*)> SessionCommand; |
| 68 |
| 69 // Executes a given session command, after acquiring access to the appropriate |
| 70 // session. |
| 71 void ExecuteSessionCommand( |
| 72 SessionThreadMap* session_thread_map, |
| 73 const SessionCommand& command, |
| 74 bool return_ok_without_session, |
| 70 const base::DictionaryValue& params, | 75 const base::DictionaryValue& params, |
| 71 const std::string& session_id, | 76 const std::string& session_id, |
| 72 scoped_ptr<base::Value>* out_value, | 77 const CommandCallback& callback); |
| 73 std::string* out_session_id); | 78 |
| 79 namespace internal { |
| 80 void CreateSessionOnSessionThreadForTesting(const std::string& id); |
| 81 } // namespace internal |
| 74 | 82 |
| 75 #endif // CHROME_TEST_CHROMEDRIVER_COMMANDS_H_ | 83 #endif // CHROME_TEST_CHROMEDRIVER_COMMANDS_H_ |
| OLD | NEW |