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

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

Issue 7629019: Revert 96556 - Let pyauto create an attached webdriver instance to manipulate web pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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
« no previous file with comments | « chrome/test/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/session.h" 5 #include "chrome/test/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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 implicit_wait_(0), 70 implicit_wait_(0),
71 has_alert_prompt_text_(false), 71 has_alert_prompt_text_(false),
72 options_(options) { 72 options_(options) {
73 SessionManager::GetInstance()->Add(this); 73 SessionManager::GetInstance()->Add(this);
74 } 74 }
75 75
76 Session::~Session() { 76 Session::~Session() {
77 SessionManager::GetInstance()->Remove(id_); 77 SessionManager::GetInstance()->Remove(id_);
78 } 78 }
79 79
80 Error* Session::Init(const Automation::BrowserOptions& options) { 80 Error* Session::Init(const FilePath& browser_exe,
81 const FilePath& user_data_dir,
82 const CommandLine& options) {
81 if (!thread_.Start()) { 83 if (!thread_.Start()) {
82 delete this; 84 delete this;
83 return new Error(kUnknownError, "Cannot start session thread"); 85 return new Error(kUnknownError, "Cannot start session thread");
84 } 86 }
85 87
86 Error* error = NULL; 88 Error* error = NULL;
87 RunSessionTask(NewRunnableMethod( 89 RunSessionTask(NewRunnableMethod(
88 this, 90 this,
89 &Session::InitOnSessionThread, 91 &Session::InitOnSessionThread,
92 browser_exe,
93 user_data_dir,
90 options, 94 options,
91 &error)); 95 &error));
92 if (error) 96 if (error)
93 Terminate(); 97 Terminate();
94 return error; 98 return error;
95 } 99 }
96 100
97 Error* Session::BeforeExecuteCommand() { 101 Error* Session::BeforeExecuteCommand() {
98 Error* error = NULL; 102 Error* error = NULL;
99 if (!options_.load_async) { 103 if (!options_.load_async) {
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 done_event.Wait(); 1117 done_event.Wait();
1114 } 1118 }
1115 1119
1116 void Session::RunSessionTaskOnSessionThread(Task* task, 1120 void Session::RunSessionTaskOnSessionThread(Task* task,
1117 base::WaitableEvent* done_event) { 1121 base::WaitableEvent* done_event) {
1118 task->Run(); 1122 task->Run();
1119 delete task; 1123 delete task;
1120 done_event->Signal(); 1124 done_event->Signal();
1121 } 1125 }
1122 1126
1123 1127 void Session::InitOnSessionThread(const FilePath& browser_exe,
1124 void Session::InitOnSessionThread(const Automation::BrowserOptions& options, 1128 const FilePath& user_data_dir,
1129 const CommandLine& options,
1125 Error** error) { 1130 Error** error) {
1126 automation_.reset(new Automation()); 1131 automation_.reset(new Automation());
1127 automation_->Init(options, error); 1132 if (browser_exe.empty()) {
1133 automation_->Init(options, user_data_dir, error);
1134 } else {
1135 automation_->InitWithBrowserPath(
1136 browser_exe, user_data_dir, options, error);
1137 }
1138
1128 if (*error) 1139 if (*error)
1129 return; 1140 return;
1130 1141
1131 std::vector<int> tab_ids; 1142 std::vector<int> tab_ids;
1132 automation_->GetTabIds(&tab_ids, error); 1143 automation_->GetTabIds(&tab_ids, error);
1133 if (*error) 1144 if (*error)
1134 return; 1145 return;
1135 if (tab_ids.empty()) { 1146 if (tab_ids.empty()) {
1136 *error = new Error(kUnknownError, "No tab ids after initialization"); 1147 *error = new Error(kUnknownError, "No tab ids after initialization");
1137 return; 1148 return;
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 if (error) 1527 if (error)
1517 return error; 1528 return error;
1518 if (!value->GetAsInteger(status)) 1529 if (!value->GetAsInteger(status))
1519 return new Error(kUnknownError, 1530 return new Error(kUnknownError,
1520 "GET_APPCACHE_STATUS script returned non-integer: " + 1531 "GET_APPCACHE_STATUS script returned non-integer: " +
1521 JsonStringify(value.get())); 1532 JsonStringify(value.get()));
1522 return NULL; 1533 return NULL;
1523 } 1534 }
1524 1535
1525 } // namespace webdriver 1536 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698