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

Unified Diff: chrome/test/webdriver/session_manager.cc

Issue 6507015: Implement the target locator commands for ChromeDriver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/webdriver/session_manager.cc
diff --git a/chrome/test/webdriver/session_manager.cc b/chrome/test/webdriver/session_manager.cc
index ed9a11392f10640ce4674e21f6667344826d540c..8c52fa21e54a8803c057230a5ca07eac51623975 100644
--- a/chrome/test/webdriver/session_manager.cc
+++ b/chrome/test/webdriver/session_manager.cc
@@ -30,20 +30,9 @@ std::string SessionManager::GetAddress() {
return hostname + ":" + port_;
}
-Session* SessionManager::Create() {
- std::string id = GenerateRandomID();
- {
- base::AutoLock lock(map_lock_);
- if (map_.find(id) != map_.end()) {
- LOG(ERROR) << "Failed to generate a unique session ID";
- return NULL;
- }
- }
-
- Session* session = new Session(id);
+void SessionManager::Add(Session* session) {
base::AutoLock lock(map_lock_);
- map_[id] = session;
- return session;
+ map_[session->id()] = session;
}
bool SessionManager::Has(const std::string& id) const {
@@ -51,23 +40,17 @@ bool SessionManager::Has(const std::string& id) const {
return map_.find(id) != map_.end();
}
-bool SessionManager::Delete(const std::string& id) {
+bool SessionManager::Remove(const std::string& id) {
std::map<std::string, Session*>::iterator it;
-
Session* session;
- {
- base::AutoLock lock(map_lock_);
- it = map_.find(id);
- if (it == map_.end()) {
- VLOG(1) << "No such session with ID " << id;
- return false;
- }
- session = it->second;
- map_.erase(it);
+ base::AutoLock lock(map_lock_);
+ it = map_.find(id);
+ if (it == map_.end()) {
+ VLOG(1) << "No such session with ID " << id;
+ return false;
}
-
- VLOG(1) << "Deleting session with ID " << id;
- delete session;
+ session = it->second;
+ map_.erase(it);
return true;
}
« chrome/test/webdriver/session.cc ('K') | « chrome/test/webdriver/session_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698