| OLD | NEW |
| 1 // Copyright (c) 2010 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 #ifndef CHROME_TEST_WEBDRIVER_SESSION_MANAGER_H_ | 5 #ifndef CHROME_TEST_WEBDRIVER_SESSION_MANAGER_H_ |
| 6 #define CHROME_TEST_WEBDRIVER_SESSION_MANAGER_H_ | 6 #define CHROME_TEST_WEBDRIVER_SESSION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/singleton.h" | 11 #include "base/singleton.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 27 std::string GetIPAddress(); | 27 std::string GetIPAddress(); |
| 28 bool SetIPAddress(const std::string& port); | 28 bool SetIPAddress(const std::string& port); |
| 29 | 29 |
| 30 Session* Create(); | 30 Session* Create(); |
| 31 bool Delete(const std::string& id); | 31 bool Delete(const std::string& id); |
| 32 bool Has(const std::string& id) const; | 32 bool Has(const std::string& id) const; |
| 33 | 33 |
| 34 Session* GetSession(const std::string& id) const; | 34 Session* GetSession(const std::string& id) const; |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 SessionManager() : addr_(""), port_(""), count_(0) {} | 37 SessionManager(); |
| 38 ~SessionManager(); |
| 38 friend struct DefaultSingletonTraits<SessionManager>; | 39 friend struct DefaultSingletonTraits<SessionManager>; |
| 39 std::string GenerateSessionID(); | 40 std::string GenerateSessionID(); |
| 40 std::string IPLookup(const std::string& nic); | 41 std::string IPLookup(const std::string& nic); |
| 41 | 42 |
| 42 std::map<std::string, Session*> map_; | 43 std::map<std::string, Session*> map_; |
| 43 mutable base::Lock map_lock_; | 44 mutable base::Lock map_lock_; |
| 44 base::Lock session_generation_; | 45 base::Lock session_generation_; |
| 45 // Record the address and port for the HTTP 303 See other redirect. | 46 // Record the address and port for the HTTP 303 See other redirect. |
| 46 // We save the IP and Port of the machine chromedriver is running on since | 47 // We save the IP and Port of the machine chromedriver is running on since |
| 47 // a HTTP 303, see other, resdirect is sent after a successful creation of | 48 // a HTTP 303, see other, resdirect is sent after a successful creation of |
| 48 // a session, ie: http://172.22.41.105:8080/session/DFSSE453CV588 | 49 // a session, ie: http://172.22.41.105:8080/session/DFSSE453CV588 |
| 49 std::string addr_; | 50 std::string addr_; |
| 50 std::string port_; | 51 std::string port_; |
| 51 int count_; | 52 int count_; |
| 52 | 53 |
| 53 DISALLOW_COPY_AND_ASSIGN(SessionManager); | 54 DISALLOW_COPY_AND_ASSIGN(SessionManager); |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 } // namespace webdriver | 57 } // namespace webdriver |
| 57 | 58 |
| 58 #endif // CHROME_TEST_WEBDRIVER_SESSION_MANAGER_H_ | 59 #endif // CHROME_TEST_WEBDRIVER_SESSION_MANAGER_H_ |
| OLD | NEW |