| OLD | NEW |
| 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_manager.h" | 5 #include "chrome/test/webdriver/session_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/test/webdriver/utility_functions.h" | 8 #include "chrome/test/webdriver/utility_functions.h" |
| 9 #include "net/base/net_util.h" | 9 #include "net/base/net_util.h" |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 bool SessionManager::Has(const std::string& id) const { | 38 bool SessionManager::Has(const std::string& id) const { |
| 39 base::AutoLock lock(map_lock_); | 39 base::AutoLock lock(map_lock_); |
| 40 return map_.find(id) != map_.end(); | 40 return map_.find(id) != map_.end(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool SessionManager::Remove(const std::string& id) { | 43 bool SessionManager::Remove(const std::string& id) { |
| 44 std::map<std::string, Session*>::iterator it; | 44 std::map<std::string, Session*>::iterator it; |
| 45 Session* session; | 45 Session* session; |
| 46 base::AutoLock lock(map_lock_); | 46 base::AutoLock lock(map_lock_); |
| 47 it = map_.find(id); | 47 it = map_.find(id); |
| 48 if (it == map_.end()) { | 48 if (it == map_.end()) |
| 49 VLOG(1) << "No such session with ID " << id; | |
| 50 return false; | 49 return false; |
| 51 } | |
| 52 session = it->second; | 50 session = it->second; |
| 53 map_.erase(it); | 51 map_.erase(it); |
| 54 return true; | 52 return true; |
| 55 } | 53 } |
| 56 | 54 |
| 57 Session* SessionManager::GetSession(const std::string& id) const { | 55 Session* SessionManager::GetSession(const std::string& id) const { |
| 58 std::map<std::string, Session*>::const_iterator it; | 56 std::map<std::string, Session*>::const_iterator it; |
| 59 base::AutoLock lock(map_lock_); | 57 base::AutoLock lock(map_lock_); |
| 60 it = map_.find(id); | 58 it = map_.find(id); |
| 61 if (it == map_.end()) { | 59 if (it == map_.end()) |
| 62 VLOG(1) << "No such session with ID " << id; | |
| 63 return NULL; | 60 return NULL; |
| 64 } | |
| 65 return it->second; | 61 return it->second; |
| 66 } | 62 } |
| 67 | 63 |
| 68 void SessionManager::set_port(const std::string& port) { | 64 void SessionManager::set_port(const std::string& port) { |
| 69 port_ = port; | 65 port_ = port; |
| 70 } | 66 } |
| 71 | 67 |
| 72 void SessionManager::set_url_base(const std::string& url_base) { | 68 void SessionManager::set_url_base(const std::string& url_base) { |
| 73 url_base_ = url_base; | 69 url_base_ = url_base; |
| 74 } | 70 } |
| 75 | 71 |
| 76 std::string SessionManager::url_base() const { | 72 std::string SessionManager::url_base() const { |
| 77 return url_base_; | 73 return url_base_; |
| 78 } | 74 } |
| 79 | 75 |
| 80 SessionManager::SessionManager() : port_(""), url_base_("") {} | 76 SessionManager::SessionManager() : port_(""), url_base_("") {} |
| 81 | 77 |
| 82 SessionManager::~SessionManager() {} | 78 SessionManager::~SessionManager() {} |
| 83 | 79 |
| 84 // static | 80 // static |
| 85 SessionManager* SessionManager::GetInstance() { | 81 SessionManager* SessionManager::GetInstance() { |
| 86 return Singleton<SessionManager>::get(); | 82 return Singleton<SessionManager>::get(); |
| 87 } | 83 } |
| 88 | 84 |
| 89 } // namespace webdriver | 85 } // namespace webdriver |
| OLD | NEW |