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

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

Issue 6330012: Cookie commands for the webdriver protocol (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: updates Created 9 years, 10 months 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/session_manager.h" 5 #include "chrome/test/webdriver/session_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/process.h" 13 #include "base/process.h"
14 #include "base/process_util.h" 14 #include "base/process_util.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/json/json_reader.h" 16 #include "base/json/json_reader.h"
17 #include "base/json/json_writer.h" 17 #include "base/json/json_writer.h"
18 #include "base/test/test_timeouts.h" 18 #include "base/test/test_timeouts.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "chrome/app/chrome_command_ids.h" 20 #include "chrome/app/chrome_command_ids.h"
21 #include "chrome/common/chrome_constants.h" 21 #include "chrome/common/chrome_constants.h"
22 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
23 #include "chrome/test/test_launcher_utils.h" 23 #include "chrome/test/test_launcher_utils.h"
24 #include "chrome/test/webdriver/utility_functions.h" 24 #include "chrome/test/webdriver/utility_functions.h"
kkania 2011/02/08 18:35:22 add include for googleurl
25 #include "third_party/webdriver/atoms.h" 25 #include "third_party/webdriver/atoms.h"
26 26
27 namespace webdriver { 27 namespace webdriver {
28 28
29 Session::Session(const std::string& id) 29 Session::Session(const std::string& id)
30 : thread_(id.c_str()), 30 : thread_(id.c_str()),
31 id_(id), 31 id_(id),
32 window_num_(0), 32 window_num_(0),
33 implicit_wait_(0), 33 implicit_wait_(0),
34 current_frame_xpath_(L"") { 34 current_frame_xpath_(L"") {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 bool Session::GetURL(std::string* url) { 168 bool Session::GetURL(std::string* url) {
169 bool success = false; 169 bool success = false;
170 RunSessionTask(NewRunnableMethod( 170 RunSessionTask(NewRunnableMethod(
171 automation_.get(), 171 automation_.get(),
172 &Automation::GetURL, 172 &Automation::GetURL,
173 url, 173 url,
174 &success)); 174 &success));
175 return success; 175 return success;
176 } 176 }
177 177
178 bool Session::GetURL(GURL* gurl) {
179 bool success = false;
180 RunSessionTask(NewRunnableMethod(
181 automation_.get(),
182 &Automation::GetGURL,
183 gurl,
184 &success));
kkania 2011/02/08 18:35:22 indent 2 more here
Joe 2011/02/09 06:32:10 Done.
185 return success;
186 }
187
178 bool Session::GetTabTitle(std::string* tab_title) { 188 bool Session::GetTabTitle(std::string* tab_title) {
179 bool success = false; 189 bool success = false;
180 RunSessionTask(NewRunnableMethod( 190 RunSessionTask(NewRunnableMethod(
181 automation_.get(), 191 automation_.get(),
182 &Automation::GetTabTitle, 192 &Automation::GetTabTitle,
183 tab_title, 193 tab_title,
184 &success)); 194 &success));
185 return success; 195 return success;
186 } 196 }
187 197
198 bool Session::GetCookies(const GURL& url, std::string* cookies) {
199 bool success = false;
200 RunSessionTask(NewRunnableMethod(
201 automation_.get(),
202 &Automation::GetCookies,
203 url,
kkania 2011/02/08 18:35:22 fix indent
Joe 2011/02/09 06:32:10 Done.
204 cookies,
205 &success));
206 return success;
207 }
208
209 bool Session::GetCookieByName(const GURL& url, const std::string& cookie_name,
kkania 2011/02/08 18:35:22 bool Session::GetCookieByName(const GURL& url,
Joe 2011/02/09 06:32:10 Done.
210 std::string* cookie) {
211 bool success = false;
212 RunSessionTask(NewRunnableMethod(
213 automation_.get(),
214 &Automation::GetCookieByName,
215 url,
216 cookie_name,
217 cookie,
218 &success));
219 return success;
220 }
221
222 bool Session::DeleteCookie(const GURL& url, const std::string& cookie_name) {
223 bool success = false;
224 RunSessionTask(NewRunnableMethod(
225 automation_.get(),
226 &Automation::DeleteCookie,
227 url,
228 cookie_name,
229 &success));
230 return success;
231 }
232
233 bool Session::SetCookie(const GURL& url, const std::string& cookie) {
234 bool success = false;
235 RunSessionTask(NewRunnableMethod(
236 automation_.get(),
237 &Automation::SetCookie,
238 url,
239 cookie,
240 &success));
241 return success;
242 }
243
188 void Session::RunSessionTask(Task* task) { 244 void Session::RunSessionTask(Task* task) {
189 base::WaitableEvent done_event(false, false); 245 base::WaitableEvent done_event(false, false);
190 thread_.message_loop_proxy()->PostTask(FROM_HERE, NewRunnableMethod( 246 thread_.message_loop_proxy()->PostTask(FROM_HERE, NewRunnableMethod(
191 this, 247 this,
192 &Session::RunSessionTaskOnSessionThread, 248 &Session::RunSessionTaskOnSessionThread,
193 task, 249 task,
194 &done_event)); 250 &done_event));
195 done_event.Wait(); 251 done_event.Wait();
196 } 252 }
197 253
198 void Session::RunSessionTaskOnSessionThread(Task* task, 254 void Session::RunSessionTaskOnSessionThread(Task* task,
199 base::WaitableEvent* done_event) { 255 base::WaitableEvent* done_event) {
200 task->Run(); 256 task->Run();
201 delete task; 257 delete task;
202 done_event->Signal(); 258 done_event->Signal();
203 } 259 }
204 260
205 void Session::InitOnSessionThread(bool* success) { 261 void Session::InitOnSessionThread(bool* success) {
206 automation_.reset(new Automation()); 262 automation_.reset(new Automation());
207 automation_->Init(success); 263 automation_->Init(success);
208 } 264 }
209 265
210 void Session::TerminateOnSessionThread() { 266 void Session::TerminateOnSessionThread() {
211 automation_->Terminate(); 267 automation_->Terminate();
212 automation_.reset(); 268 automation_.reset();
213 } 269 }
214 270
215 } // namespace webdriver 271 } // namespace webdriver
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698