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