| 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 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 const base::TimeDelta Session::kDefaultPageLoadTimeout = | 32 const base::TimeDelta Session::kDefaultPageLoadTimeout = |
| 33 base::TimeDelta::FromMinutes(5); | 33 base::TimeDelta::FromMinutes(5); |
| 34 | 34 |
| 35 Session::Session(const std::string& id) | 35 Session::Session(const std::string& id) |
| 36 : id(id), | 36 : id(id), |
| 37 quit(false), | 37 quit(false), |
| 38 detach(false), | 38 detach(false), |
| 39 force_devtools_screenshot(false), | 39 force_devtools_screenshot(false), |
| 40 sticky_modifiers(0), | 40 sticky_modifiers(0), |
| 41 mouse_position(0, 0), | 41 mouse_position(0, 0), |
| 42 page_load_timeout(kDefaultPageLoadTimeout) {} | 42 page_load_timeout(kDefaultPageLoadTimeout), |
| 43 auto_reporting_enabled(false) {} |
| 43 | 44 |
| 44 Session::Session(const std::string& id, scoped_ptr<Chrome> chrome) | 45 Session::Session(const std::string& id, scoped_ptr<Chrome> chrome) |
| 45 : id(id), | 46 : id(id), |
| 46 quit(false), | 47 quit(false), |
| 47 detach(false), | 48 detach(false), |
| 48 force_devtools_screenshot(false), | 49 force_devtools_screenshot(false), |
| 49 chrome(chrome.Pass()), | 50 chrome(chrome.Pass()), |
| 50 sticky_modifiers(0), | 51 sticky_modifiers(0), |
| 51 mouse_position(0, 0), | 52 mouse_position(0, 0), |
| 52 page_load_timeout(kDefaultPageLoadTimeout) {} | 53 page_load_timeout(kDefaultPageLoadTimeout), |
| 54 auto_reporting_enabled(false) {} |
| 53 | 55 |
| 54 Session::~Session() {} | 56 Session::~Session() {} |
| 55 | 57 |
| 56 Status Session::GetTargetWindow(WebView** web_view) { | 58 Status Session::GetTargetWindow(WebView** web_view) { |
| 57 if (!chrome) | 59 if (!chrome) |
| 58 return Status(kNoSuchWindow, "no chrome started in this session"); | 60 return Status(kNoSuchWindow, "no chrome started in this session"); |
| 59 | 61 |
| 60 Status status = chrome->GetWebViewById(window, web_view); | 62 Status status = chrome->GetWebViewById(window, web_view); |
| 61 if (status.IsError()) | 63 if (status.IsError()) |
| 62 status = Status(kNoSuchWindow, "target window already closed", status); | 64 status = Status(kNoSuchWindow, "target window already closed", status); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 86 for (ScopedVector<WebDriverLog>::const_iterator log = devtools_logs.begin(); | 88 for (ScopedVector<WebDriverLog>::const_iterator log = devtools_logs.begin(); |
| 87 log != devtools_logs.end(); | 89 log != devtools_logs.end(); |
| 88 ++log) { | 90 ++log) { |
| 89 logs.push_back(*log); | 91 logs.push_back(*log); |
| 90 } | 92 } |
| 91 if (driver_log) | 93 if (driver_log) |
| 92 logs.push_back(driver_log.get()); | 94 logs.push_back(driver_log.get()); |
| 93 return logs; | 95 return logs; |
| 94 } | 96 } |
| 95 | 97 |
| 98 std::string Session::GetFirstBrowserError() const { |
| 99 for (ScopedVector<WebDriverLog>::const_iterator it = devtools_logs.begin(); |
| 100 it != devtools_logs.end(); |
| 101 ++it) { |
| 102 if ((*it)->type() == WebDriverLog::kBrowserType) { |
| 103 std::string message = (*it)->GetFirstErrorMessage(); |
| 104 if (!message.empty()) |
| 105 return message; |
| 106 } |
| 107 } |
| 108 return std::string(); |
| 109 } |
| 110 |
| 96 Session* GetThreadLocalSession() { | 111 Session* GetThreadLocalSession() { |
| 97 return lazy_tls_session.Pointer()->Get(); | 112 return lazy_tls_session.Pointer()->Get(); |
| 98 } | 113 } |
| 99 | 114 |
| 100 void SetThreadLocalSession(scoped_ptr<Session> session) { | 115 void SetThreadLocalSession(scoped_ptr<Session> session) { |
| 101 lazy_tls_session.Pointer()->Set(session.release()); | 116 lazy_tls_session.Pointer()->Set(session.release()); |
| 102 } | 117 } |
| OLD | NEW |