diff options
author | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-07 18:12:57 +0000 |
---|---|---|
committer | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-07 18:12:57 +0000 |
commit | 75895ca88b16d4d80f5cdbb3132bbe9682601aa7 (patch) | |
tree | 4acd34948ac8cc93f4e320a5b98d1635edbdf0de /chrome/test/webdriver/session.cc | |
parent | 4f86f27ff9541cd91d4834a9c8163f5751d26e93 (diff) | |
download | chromium_src-75895ca88b16d4d80f5cdbb3132bbe9682601aa7.zip chromium_src-75895ca88b16d4d80f5cdbb3132bbe9682601aa7.tar.gz chromium_src-75895ca88b16d4d80f5cdbb3132bbe9682601aa7.tar.bz2 |
Introduce a ChromeDriver automation version constant and a JSON request
for the client to fetch the server's version. If the server's version is
newer than the client's, warn the client and quit.
Additional small changes:
-Add /healthz callback that sends a 200 status, for checking if the server is up.
-Fix shutdown crash where the AutomationProxy is deleted on the wrong thread.
-Initialize logging correctly.
-Disable mongoose file serving capabilities by default
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6690060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80813 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/webdriver/session.cc')
-rw-r--r-- | chrome/test/webdriver/session.cc | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/chrome/test/webdriver/session.cc b/chrome/test/webdriver/session.cc index 693b574..55aa190 100644 --- a/chrome/test/webdriver/session.cc +++ b/chrome/test/webdriver/session.cc @@ -69,20 +69,22 @@ Session::~Session() { SessionManager::GetInstance()->Remove(id_); } -bool Session::Init(const FilePath& browser_dir) { - bool success = false; - if (thread_.Start()) { - RunSessionTask(NewRunnableMethod( - this, - &Session::InitOnSessionThread, - browser_dir, - &success)); - } else { +ErrorCode Session::Init(const FilePath& browser_dir) { + if (!thread_.Start()) { LOG(ERROR) << "Cannot start session thread"; - } - if (!success) delete this; - return success; + return kUnknownError; + } + + ErrorCode code = kUnknownError; + RunSessionTask(NewRunnableMethod( + this, + &Session::InitOnSessionThread, + browser_dir, + &code)); + if (code != kSuccess) + Terminate(); + return code; } void Session::Terminate() { @@ -903,24 +905,27 @@ void Session::RunSessionTaskOnSessionThread(Task* task, done_event->Signal(); } -void Session::InitOnSessionThread(const FilePath& browser_dir, bool* success) { +void Session::InitOnSessionThread(const FilePath& browser_dir, + ErrorCode* code) { automation_.reset(new Automation()); - automation_->Init(browser_dir, success); - if (!*success) + automation_->Init(browser_dir, code); + if (*code != kSuccess) return; + bool success = false; std::vector<int> tab_ids; - automation_->GetTabIds(&tab_ids, success); - if (!*success) { + automation_->GetTabIds(&tab_ids, &success); + if (!success) { LOG(ERROR) << "Could not get tab ids"; + *code = kUnknownError; return; } if (tab_ids.empty()) { LOG(ERROR) << "No tab ids after initialization"; - *success = false; - } else { - current_target_ = FrameId(tab_ids[0], FramePath()); + *code = kUnknownError; + return; } + current_target_ = FrameId(tab_ids[0], FramePath()); } void Session::TerminateOnSessionThread() { |