| Index: chrome/test/chromedriver/session.cc
|
| diff --git a/chrome/test/chromedriver/session.cc b/chrome/test/chromedriver/session.cc
|
| index 3dc1e01f9b0426dc8a88a284f22e55aba0a7bad6..80b441852bf332794a57a062248c9d4a714edb48 100644
|
| --- a/chrome/test/chromedriver/session.cc
|
| +++ b/chrome/test/chromedriver/session.cc
|
| @@ -6,6 +6,8 @@
|
|
|
| #include <list>
|
|
|
| +#include "base/lazy_instance.h"
|
| +#include "base/threading/thread_local.h"
|
| #include "base/values.h"
|
| #include "chrome/test/chromedriver/chrome/chrome.h"
|
| #include "chrome/test/chromedriver/chrome/status.h"
|
| @@ -13,6 +15,13 @@
|
| #include "chrome/test/chromedriver/chrome/web_view.h"
|
| #include "chrome/test/chromedriver/logging.h"
|
|
|
| +namespace {
|
| +
|
| +base::LazyInstance<base::ThreadLocalPointer<Session> >
|
| + lazy_tls_session = LAZY_INSTANCE_INITIALIZER;
|
| +
|
| +} // namespace
|
| +
|
| FrameInfo::FrameInfo(const std::string& parent_frame_id,
|
| const std::string& frame_id,
|
| const std::string& chromedriver_frame_id)
|
| @@ -33,15 +42,14 @@ Session::Session(const std::string& id)
|
| page_load_timeout(kDefaultPageLoadTimeout) {}
|
|
|
| Session::Session(const std::string& id, scoped_ptr<Chrome> chrome)
|
| - : id(id),
|
| + : id(id)
|
| quit(false),
|
| detach(false),
|
| force_devtools_screenshot(false),
|
| chrome(chrome.Pass()),
|
| sticky_modifiers(0),
|
| mouse_position(0, 0),
|
| - page_load_timeout(kDefaultPageLoadTimeout),
|
| - capabilities(CreateCapabilities()) {}
|
| + page_load_timeout(kDefaultPageLoadTimeout) {}
|
|
|
| Session::~Session() {}
|
|
|
| @@ -73,23 +81,22 @@ std::string Session::GetCurrentFrameId() const {
|
| return frames.back().frame_id;
|
| }
|
|
|
| -scoped_ptr<base::DictionaryValue> Session::CreateCapabilities() {
|
| - scoped_ptr<base::DictionaryValue> caps(new base::DictionaryValue());
|
| - caps->SetString("browserName", "chrome");
|
| - caps->SetString("version", chrome->GetVersion());
|
| - caps->SetString("chrome.chromedriverVersion", kChromeDriverVersion);
|
| - caps->SetString("platform", chrome->GetOperatingSystemName());
|
| - caps->SetBoolean("javascriptEnabled", true);
|
| - caps->SetBoolean("takesScreenshot", true);
|
| - caps->SetBoolean("handlesAlerts", true);
|
| - caps->SetBoolean("databaseEnabled", true);
|
| - caps->SetBoolean("locationContextEnabled", true);
|
| - caps->SetBoolean("applicationCacheEnabled", false);
|
| - caps->SetBoolean("browserConnectionEnabled", false);
|
| - caps->SetBoolean("cssSelectorsEnabled", true);
|
| - caps->SetBoolean("webStorageEnabled", true);
|
| - caps->SetBoolean("rotatable", false);
|
| - caps->SetBoolean("acceptSslCerts", true);
|
| - caps->SetBoolean("nativeEvents", true);
|
| - return caps.Pass();
|
| +std::vector<WebDriverLog*> Session::GetAllLogs() const {
|
| + std::vector<WebDriverLog*> logs;
|
| + for (ScopedVector<WebDriverLog>::const_iterator log = devtools_logs.begin();
|
| + log != devtools_logs.end();
|
| + ++log) {
|
| + logs.push_back(*log);
|
| + }
|
| + if (driver_log)
|
| + logs.push_back(driver_log.get());
|
| + return logs;
|
| +}
|
| +
|
| +Session* GetThreadLocalSession() {
|
| + return lazy_tls_session.Pointer()->Get();
|
| +}
|
| +
|
| +void SetThreadLocalSession(scoped_ptr<Session> session) {
|
| + lazy_tls_session.Pointer()->Set(session.release());
|
| }
|
|
|