Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/test/webdriver/webdriver_session.cc

Issue 8401007: Don't run the pre and post handlers after chromedriver receives a termination request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/webdriver/webdriver_session.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/webdriver/webdriver_session.h" 5 #include "chrome/test/webdriver/webdriver_session.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 Session::Options::~Options() { 60 Session::Options::~Options() {
61 } 61 }
62 62
63 Session::Session(const Options& options) 63 Session::Session(const Options& options)
64 : id_(GenerateRandomID()), 64 : id_(GenerateRandomID()),
65 current_target_(FrameId(0, FramePath())), 65 current_target_(FrameId(0, FramePath())),
66 thread_(id_.c_str()), 66 thread_(id_.c_str()),
67 async_script_timeout_(0), 67 async_script_timeout_(0),
68 implicit_wait_(0), 68 implicit_wait_(0),
69 has_alert_prompt_text_(false), 69 has_alert_prompt_text_(false),
70 terminated_(false),
70 options_(options) { 71 options_(options) {
71 SessionManager::GetInstance()->Add(this); 72 SessionManager::GetInstance()->Add(this);
72 } 73 }
73 74
74 Session::~Session() { 75 Session::~Session() {
75 SessionManager::GetInstance()->Remove(id_); 76 SessionManager::GetInstance()->Remove(id_);
76 } 77 }
77 78
78 Error* Session::Init(const Automation::BrowserOptions& options) { 79 Error* Session::Init(const Automation::BrowserOptions& options) {
79 if (!thread_.Start()) { 80 if (!thread_.Start()) {
80 delete this; 81 delete this;
81 return new Error(kUnknownError, "Cannot start session thread"); 82 return new Error(kUnknownError, "Cannot start session thread");
82 } 83 }
83 84
84 Error* error = NULL; 85 Error* error = NULL;
85 RunSessionTask(NewRunnableMethod( 86 RunSessionTask(NewRunnableMethod(
86 this, 87 this,
87 &Session::InitOnSessionThread, 88 &Session::InitOnSessionThread,
88 options, 89 options,
89 &error)); 90 &error));
90 if (error) 91 if (error)
91 Terminate(); 92 Terminate();
92 return error; 93 return error;
93 } 94 }
94 95
95 Error* Session::BeforeExecuteCommand() { 96 Error* Session::BeforeExecuteCommand() {
97 if (terminated_)
98 return NULL;
96 Error* error = AfterExecuteCommand(); 99 Error* error = AfterExecuteCommand();
97 if (!error) { 100 if (!error) {
98 scoped_ptr<Error> switch_error(SwitchToTopFrameIfCurrentFrameInvalid()); 101 scoped_ptr<Error> switch_error(SwitchToTopFrameIfCurrentFrameInvalid());
99 if (switch_error.get()) { 102 if (switch_error.get()) {
100 std::string text; 103 std::string text;
101 scoped_ptr<Error> alert_error(GetAlertMessage(&text)); 104 scoped_ptr<Error> alert_error(GetAlertMessage(&text));
102 if (alert_error.get()) { 105 if (alert_error.get()) {
103 // Only return a frame checking error if a modal dialog is not present. 106 // Only return a frame checking error if a modal dialog is not present.
104 // TODO(kkania): This is ugly. Fix. 107 // TODO(kkania): This is ugly. Fix.
105 return switch_error.release(); 108 return switch_error.release();
106 } 109 }
107 } 110 }
108 } 111 }
109 return error; 112 return error;
110 } 113 }
111 114
112 Error* Session::AfterExecuteCommand() { 115 Error* Session::AfterExecuteCommand() {
116 if (terminated_)
117 return NULL;
113 Error* error = NULL; 118 Error* error = NULL;
114 if (!options_.load_async) { 119 if (!options_.load_async) {
115 LOG(INFO) << "Waiting for the page to stop loading"; 120 LOG(INFO) << "Waiting for the page to stop loading";
116 error = WaitForAllTabsToStopLoading(); 121 error = WaitForAllTabsToStopLoading();
117 LOG(INFO) << "Done waiting for the page to stop loading"; 122 LOG(INFO) << "Done waiting for the page to stop loading";
118 } 123 }
119 return error; 124 return error;
120 } 125 }
121 126
122 void Session::Terminate() { 127 void Session::Terminate() {
128 terminated_ = true;
123 RunSessionTask(NewRunnableMethod( 129 RunSessionTask(NewRunnableMethod(
124 this, 130 this,
125 &Session::TerminateOnSessionThread)); 131 &Session::TerminateOnSessionThread));
126 delete this; 132 delete this;
127 } 133 }
128 134
129 Error* Session::ExecuteScript(const FrameId& frame_id, 135 Error* Session::ExecuteScript(const FrameId& frame_id,
130 const std::string& script, 136 const std::string& script,
131 const ListValue* const args, 137 const ListValue* const args,
132 Value** value) { 138 Value** value) {
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 Error* Session::GetAppCacheStatus(int* status) { 1436 Error* Session::GetAppCacheStatus(int* status) {
1431 return ExecuteScriptAndParse( 1437 return ExecuteScriptAndParse(
1432 current_target_, 1438 current_target_,
1433 atoms::asString(atoms::GET_APPCACHE_STATUS), 1439 atoms::asString(atoms::GET_APPCACHE_STATUS),
1434 "getAppcacheStatus", 1440 "getAppcacheStatus",
1435 new ListValue(), 1441 new ListValue(),
1436 CreateDirectValueParser(status)); 1442 CreateDirectValueParser(status));
1437 } 1443 }
1438 1444
1439 } // namespace webdriver 1445 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/webdriver_session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698