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> |
| 8 |
7 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
8 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
9 #include "base/values.h" | 11 #include "base/values.h" |
10 #include "chrome/test/chromedriver/capabilities.h" | 12 #include "chrome/test/chromedriver/capabilities.h" |
11 #include "chrome/test/chromedriver/chrome/chrome.h" | 13 #include "chrome/test/chromedriver/chrome/chrome.h" |
12 #include "chrome/test/chromedriver/chrome/chrome_android_impl.h" | 14 #include "chrome/test/chromedriver/chrome/chrome_android_impl.h" |
13 #include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h" | 15 #include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h" |
| 16 #include "chrome/test/chromedriver/chrome/devtools_event_logger.h" |
14 #include "chrome/test/chromedriver/chrome/status.h" | 17 #include "chrome/test/chromedriver/chrome/status.h" |
15 #include "chrome/test/chromedriver/chrome/version.h" | 18 #include "chrome/test/chromedriver/chrome/version.h" |
16 #include "chrome/test/chromedriver/chrome/web_view.h" | 19 #include "chrome/test/chromedriver/chrome/web_view.h" |
17 #include "chrome/test/chromedriver/chrome_launcher.h" | 20 #include "chrome/test/chromedriver/chrome_launcher.h" |
| 21 #include "chrome/test/chromedriver/logging.h" |
18 #include "chrome/test/chromedriver/net/net_util.h" | 22 #include "chrome/test/chromedriver/net/net_util.h" |
19 #include "chrome/test/chromedriver/net/url_request_context_getter.h" | 23 #include "chrome/test/chromedriver/net/url_request_context_getter.h" |
20 #include "chrome/test/chromedriver/session.h" | 24 #include "chrome/test/chromedriver/session.h" |
21 #include "chrome/test/chromedriver/session_map.h" | 25 #include "chrome/test/chromedriver/session_map.h" |
22 #include "chrome/test/chromedriver/util.h" | 26 #include "chrome/test/chromedriver/util.h" |
23 | 27 |
24 Status ExecuteGetStatus( | 28 Status ExecuteGetStatus( |
25 const base::DictionaryValue& params, | 29 const base::DictionaryValue& params, |
26 const std::string& session_id, | 30 const std::string& session_id, |
27 scoped_ptr<base::Value>* out_value, | 31 scoped_ptr<base::Value>* out_value, |
(...skipping 27 matching lines...) Expand all Loading... |
55 | 59 |
56 const base::DictionaryValue* desired_caps; | 60 const base::DictionaryValue* desired_caps; |
57 if (!params.GetDictionary("desiredCapabilities", &desired_caps)) | 61 if (!params.GetDictionary("desiredCapabilities", &desired_caps)) |
58 return Status(kUnknownError, "cannot find dict 'desiredCapabilities'"); | 62 return Status(kUnknownError, "cannot find dict 'desiredCapabilities'"); |
59 | 63 |
60 Capabilities capabilities; | 64 Capabilities capabilities; |
61 Status status = capabilities.Parse(*desired_caps); | 65 Status status = capabilities.Parse(*desired_caps); |
62 if (status.IsError()) | 66 if (status.IsError()) |
63 return status; | 67 return status; |
64 | 68 |
| 69 // Create DevToolsEventLoggers, fail if log levels are invalid. |
| 70 ScopedVector<DevToolsEventLogger> devtools_event_loggers; |
| 71 status = CreateLoggers(capabilities, &devtools_event_loggers); |
| 72 if (status.IsError()) |
| 73 return status; |
| 74 |
65 scoped_ptr<Chrome> chrome; | 75 scoped_ptr<Chrome> chrome; |
| 76 std::list<DevToolsEventLogger*> devtools_event_logger_list( |
| 77 devtools_event_loggers.begin(), devtools_event_loggers.end()); |
66 status = LaunchChrome(context_getter, port, socket_factory, | 78 status = LaunchChrome(context_getter, port, socket_factory, |
67 capabilities, &chrome); | 79 capabilities, devtools_event_logger_list, &chrome); |
68 if (status.IsError()) | 80 if (status.IsError()) |
69 return status; | 81 return status; |
70 | 82 |
71 std::list<std::string> web_view_ids; | 83 std::list<std::string> web_view_ids; |
72 status = chrome->GetWebViewIds(&web_view_ids); | 84 status = chrome->GetWebViewIds(&web_view_ids); |
73 if (status.IsError() || web_view_ids.empty()) { | 85 if (status.IsError() || web_view_ids.empty()) { |
74 chrome->Quit(); | 86 chrome->Quit(); |
75 return status.IsError() ? status : | 87 return status.IsError() ? status : |
76 Status(kUnknownError, "unable to discover open window in chrome"); | 88 Status(kUnknownError, "unable to discover open window in chrome"); |
77 } | 89 } |
78 | 90 |
79 std::string new_id = session_id; | 91 std::string new_id = session_id; |
80 if (new_id.empty()) | 92 if (new_id.empty()) |
81 new_id = GenerateId(); | 93 new_id = GenerateId(); |
82 scoped_ptr<Session> session(new Session(new_id, chrome.Pass())); | 94 scoped_ptr<Session> session(new Session(new_id, chrome.Pass())); |
| 95 session->devtools_event_loggers.swap(devtools_event_loggers); |
83 if (!session->thread.Start()) { | 96 if (!session->thread.Start()) { |
84 chrome->Quit(); | 97 chrome->Quit(); |
85 return Status(kUnknownError, | 98 return Status(kUnknownError, |
86 "failed to start a thread for the new session"); | 99 "failed to start a thread for the new session"); |
87 } | 100 } |
88 session->window = web_view_ids.front(); | 101 session->window = web_view_ids.front(); |
89 out_value->reset(session->capabilities->DeepCopy()); | 102 out_value->reset(session->capabilities->DeepCopy()); |
90 *out_session_id = new_id; | 103 *out_session_id = new_id; |
91 | 104 |
92 scoped_refptr<SessionAccessor> accessor( | 105 scoped_refptr<SessionAccessor> accessor( |
(...skipping 12 matching lines...) Expand all Loading... |
105 std::string* out_session_id) { | 118 std::string* out_session_id) { |
106 std::vector<std::string> session_ids; | 119 std::vector<std::string> session_ids; |
107 session_map->GetKeys(&session_ids); | 120 session_map->GetKeys(&session_ids); |
108 for (size_t i = 0; i < session_ids.size(); ++i) { | 121 for (size_t i = 0; i < session_ids.size(); ++i) { |
109 scoped_ptr<base::Value> unused_value; | 122 scoped_ptr<base::Value> unused_value; |
110 std::string unused_session_id; | 123 std::string unused_session_id; |
111 quit_command.Run(params, session_ids[i], &unused_value, &unused_session_id); | 124 quit_command.Run(params, session_ids[i], &unused_value, &unused_session_id); |
112 } | 125 } |
113 return Status(kOk); | 126 return Status(kOk); |
114 } | 127 } |
OLD | NEW |