| 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 #include "chrome/test/chromedriver/commands.h" | 5 #include "chrome/test/chromedriver/commands.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 os.SetString("arch", base::SysInfo::OperatingSystemArchitecture()); | 49 os.SetString("arch", base::SysInfo::OperatingSystemArchitecture()); |
| 50 | 50 |
| 51 base::DictionaryValue info; | 51 base::DictionaryValue info; |
| 52 info.Set("build", build.DeepCopy()); | 52 info.Set("build", build.DeepCopy()); |
| 53 info.Set("os", os.DeepCopy()); | 53 info.Set("os", os.DeepCopy()); |
| 54 callback.Run( | 54 callback.Run( |
| 55 Status(kOk), scoped_ptr<base::Value>(info.DeepCopy()), std::string()); | 55 Status(kOk), scoped_ptr<base::Value>(info.DeepCopy()), std::string()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 NewSessionParams::NewSessionParams( | 58 NewSessionParams::NewSessionParams( |
| 59 Log* log, | |
| 60 SessionThreadMap* session_thread_map, | 59 SessionThreadMap* session_thread_map, |
| 61 scoped_refptr<URLRequestContextGetter> context_getter, | 60 scoped_refptr<URLRequestContextGetter> context_getter, |
| 62 const SyncWebSocketFactory& socket_factory, | 61 const SyncWebSocketFactory& socket_factory, |
| 63 DeviceManager* device_manager) | 62 DeviceManager* device_manager) |
| 64 : log(log), | 63 : session_thread_map(session_thread_map), |
| 65 session_thread_map(session_thread_map), | |
| 66 context_getter(context_getter), | 64 context_getter(context_getter), |
| 67 socket_factory(socket_factory), | 65 socket_factory(socket_factory), |
| 68 device_manager(device_manager) {} | 66 device_manager(device_manager) {} |
| 69 | 67 |
| 70 NewSessionParams::~NewSessionParams() {} | 68 NewSessionParams::~NewSessionParams() {} |
| 71 | 69 |
| 72 namespace { | 70 namespace { |
| 73 | 71 |
| 74 base::LazyInstance<base::ThreadLocalPointer<Session> > | 72 base::LazyInstance<base::ThreadLocalPointer<Session> > |
| 75 lazy_tls_session = LAZY_INSTANCE_INITIALIZER; | 73 lazy_tls_session = LAZY_INSTANCE_INITIALIZER; |
| 76 | 74 |
| 77 Status CreateSessionOnSessionThreadHelper( | 75 Status CreateSessionOnSessionThreadHelper( |
| 78 const NewSessionParams& bound_params, | 76 const NewSessionParams& bound_params, |
| 79 const base::DictionaryValue& params, | 77 const base::DictionaryValue& params, |
| 80 const std::string& session_id, | 78 const std::string& session_id, |
| 81 scoped_ptr<base::Value>* out_value) { | 79 scoped_ptr<base::Value>* out_value) { |
| 82 const base::DictionaryValue* desired_caps; | 80 const base::DictionaryValue* desired_caps; |
| 83 if (!params.GetDictionary("desiredCapabilities", &desired_caps)) | 81 if (!params.GetDictionary("desiredCapabilities", &desired_caps)) |
| 84 return Status(kUnknownError, "cannot find dict 'desiredCapabilities'"); | 82 return Status(kUnknownError, "cannot find dict 'desiredCapabilities'"); |
| 85 | 83 |
| 86 Capabilities capabilities; | 84 Capabilities capabilities; |
| 87 Status status = capabilities.Parse(*desired_caps, bound_params.log); | 85 Status status = capabilities.Parse(*desired_caps); |
| 88 if (status.IsError()) | 86 if (status.IsError()) |
| 89 return status; | 87 return status; |
| 90 | 88 |
| 91 // Create Log's and DevToolsEventListener's for ones that are DevTools-based. | 89 // Create Log's and DevToolsEventListener's for ones that are DevTools-based. |
| 92 // Session will own the Log's, Chrome will own the listeners. | 90 // Session will own the Log's, Chrome will own the listeners. |
| 93 ScopedVector<WebDriverLog> devtools_logs; | 91 ScopedVector<WebDriverLog> devtools_logs; |
| 92 // TODO(kkania): Save this log in the session. |
| 93 scoped_ptr<WebDriverLog> driver_log; |
| 94 ScopedVector<DevToolsEventListener> devtools_event_listeners; | 94 ScopedVector<DevToolsEventListener> devtools_event_listeners; |
| 95 status = CreateLogs(capabilities, &devtools_logs, &devtools_event_listeners); | 95 status = CreateLogs( |
| 96 capabilities, &devtools_logs, &driver_log, &devtools_event_listeners); |
| 96 if (status.IsError()) | 97 if (status.IsError()) |
| 97 return status; | 98 return status; |
| 98 | 99 |
| 99 scoped_ptr<Chrome> chrome; | 100 scoped_ptr<Chrome> chrome; |
| 100 status = LaunchChrome(bound_params.context_getter.get(), | 101 status = LaunchChrome(bound_params.context_getter.get(), |
| 101 bound_params.socket_factory, | 102 bound_params.socket_factory, |
| 102 bound_params.log, | |
| 103 bound_params.device_manager, | 103 bound_params.device_manager, |
| 104 capabilities, | 104 capabilities, |
| 105 devtools_event_listeners, | 105 devtools_event_listeners, |
| 106 &chrome); | 106 &chrome); |
| 107 if (status.IsError()) | 107 if (status.IsError()) |
| 108 return status; | 108 return status; |
| 109 | 109 |
| 110 std::list<std::string> web_view_ids; | 110 std::list<std::string> web_view_ids; |
| 111 status = chrome->GetWebViewIds(&web_view_ids); | 111 status = chrome->GetWebViewIds(&web_view_ids); |
| 112 if (status.IsError() || web_view_ids.empty()) { | 112 if (status.IsError() || web_view_ids.empty()) { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 | 290 |
| 291 namespace internal { | 291 namespace internal { |
| 292 | 292 |
| 293 void CreateSessionOnSessionThreadForTesting(const std::string& id) { | 293 void CreateSessionOnSessionThreadForTesting(const std::string& id) { |
| 294 lazy_tls_session.Pointer()->Set(new Session(id)); | 294 lazy_tls_session.Pointer()->Set(new Session(id)); |
| 295 } | 295 } |
| 296 | 296 |
| 297 } // namespace internal | 297 } // namespace internal |
| OLD | NEW |