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/session.h" | 5 #include "chrome/test/chromedriver/session.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 std::string Session::GetCurrentFrameId() const { | 87 std::string Session::GetCurrentFrameId() const { |
88 if (frames.empty()) | 88 if (frames.empty()) |
89 return std::string(); | 89 return std::string(); |
90 return frames.back().frame_id; | 90 return frames.back().frame_id; |
91 } | 91 } |
92 | 92 |
93 std::vector<WebDriverLog*> Session::GetAllLogs() const { | 93 std::vector<WebDriverLog*> Session::GetAllLogs() const { |
94 std::vector<WebDriverLog*> logs; | 94 std::vector<WebDriverLog*> logs; |
95 for (ScopedVector<WebDriverLog>::const_iterator log = devtools_logs.begin(); | 95 for (const auto& log : devtools_logs) |
96 log != devtools_logs.end(); | 96 logs.push_back(log.get()); |
97 ++log) { | |
98 logs.push_back(*log); | |
99 } | |
100 if (driver_log) | 97 if (driver_log) |
101 logs.push_back(driver_log.get()); | 98 logs.push_back(driver_log.get()); |
102 return logs; | 99 return logs; |
103 } | 100 } |
104 | 101 |
105 std::string Session::GetFirstBrowserError() const { | 102 std::string Session::GetFirstBrowserError() const { |
106 for (ScopedVector<WebDriverLog>::const_iterator it = devtools_logs.begin(); | 103 for (const auto& log : devtools_logs) { |
107 it != devtools_logs.end(); | 104 if (log->type() == WebDriverLog::kBrowserType) { |
108 ++it) { | 105 std::string message = log->GetFirstErrorMessage(); |
109 if ((*it)->type() == WebDriverLog::kBrowserType) { | |
110 std::string message = (*it)->GetFirstErrorMessage(); | |
111 if (!message.empty()) | 106 if (!message.empty()) |
112 return message; | 107 return message; |
113 } | 108 } |
114 } | 109 } |
115 return std::string(); | 110 return std::string(); |
116 } | 111 } |
117 | 112 |
118 Session* GetThreadLocalSession() { | 113 Session* GetThreadLocalSession() { |
119 return lazy_tls_session.Pointer()->Get(); | 114 return lazy_tls_session.Pointer()->Get(); |
120 } | 115 } |
121 | 116 |
122 void SetThreadLocalSession(std::unique_ptr<Session> session) { | 117 void SetThreadLocalSession(std::unique_ptr<Session> session) { |
123 lazy_tls_session.Pointer()->Set(session.release()); | 118 lazy_tls_session.Pointer()->Set(session.release()); |
124 } | 119 } |
OLD | NEW |