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

Side by Side Diff: chrome/test/webdriver/commands/create_session.cc

Issue 6507015: Implement the target locator commands for ChromeDriver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address Jason's concerns 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/commands/create_session.h" 5 #include "chrome/test/webdriver/commands/create_session.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 9
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/common/chrome_constants.h" 12 #include "chrome/common/chrome_constants.h"
13 #include "chrome/test/webdriver/session.h" 13 #include "chrome/test/webdriver/session.h"
14 #include "chrome/test/webdriver/session_manager.h" 14 #include "chrome/test/webdriver/session_manager.h"
15 15
16 namespace webdriver { 16 namespace webdriver {
17 17
18 void CreateSession::ExecutePost(Response* const response) { 18 void CreateSession::ExecutePost(Response* const response) {
19 SessionManager* session_manager = SessionManager::GetInstance(); 19 // Session manages its own liftime, so do not call delete.
20 Session* session = session_manager->Create(); 20 Session* session = new Session();
21 if (!session) {
22 SET_WEBDRIVER_ERROR(response,
23 "Failed to create session",
24 kInternalServerError);
25 return;
26 }
27
28 std::string session_id = session->id();
29 if (!session->Init()) { 21 if (!session->Init()) {
30 session_manager->Delete(session_id);
31 SET_WEBDRIVER_ERROR(response, 22 SET_WEBDRIVER_ERROR(response,
32 "Failed to initialize session", 23 "Failed to initialize session",
33 kInternalServerError); 24 kInternalServerError);
34 return; 25 return;
35 } 26 }
36 27
37 VLOG(1) << "Created session " << session_id; 28 SessionManager* session_manager = SessionManager::GetInstance();
29 VLOG(1) << "Created session " << session->id();
38 std::ostringstream stream; 30 std::ostringstream stream;
39 stream << "http://" << session_manager->GetAddress() << "/session/" 31 stream << "http://" << session_manager->GetAddress() << "/session/"
40 << session_id; 32 << session->id();
41 response->set_status(kSeeOther); 33 response->set_status(kSeeOther);
42 response->set_value(Value::CreateStringValue(stream.str())); 34 response->set_value(Value::CreateStringValue(stream.str()));
43 } 35 }
44 36
45 } // namespace webdriver 37 } // namespace webdriver
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698