OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_TEST_WEBDRIVER_SESSION_MANAGER_H_ |
| 6 #define CHROME_TEST_WEBDRIVER_SESSION_MANAGER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 |
| 11 #include "base/singleton.h" |
| 12 |
| 13 #include "chrome/test/webdriver/session.h" |
| 14 |
| 15 namespace webdriver { |
| 16 |
| 17 // Session manager keeps track of all of the session that are currently |
| 18 // running on the machine under test. With webdriver the user is allowed |
| 19 // multiple instances of the browser on the same machine. So 2 sessions |
| 20 // open would mean you would have 2 instances of chrome running under |
| 21 // their own profiles. |
| 22 class SessionManager { |
| 23 public: |
| 24 std::string GetIPAddress(); |
| 25 bool SetIPAddress(const std::string& port); |
| 26 |
| 27 bool Create(std::string* id); |
| 28 bool Delete(const std::string& id); |
| 29 bool Has(const std::string& id) const; |
| 30 |
| 31 Session* GetSession(const std::string& id) const; |
| 32 |
| 33 private: |
| 34 SessionManager() : addr_(""), port_(""), count_(0) {} |
| 35 friend struct DefaultSingletonTraits<SessionManager>; |
| 36 std::string GenerateSessionID(); |
| 37 std::string IPLookup(const std::string& nic); |
| 38 |
| 39 std::map<std::string, Session*> map_; |
| 40 Lock session_generation_; |
| 41 // Record the address and port for the HTTP 303 See other redirect. |
| 42 // We save the IP and Port of the machine chromedriver is running on since |
| 43 // a HTTP 303, see other, resdirect is sent after a successful creation of |
| 44 // a session, ie: http://172.22.41.105:8080/session/DFSSE453CV588 |
| 45 std::string addr_; |
| 46 std::string port_; |
| 47 int count_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(SessionManager); |
| 50 }; |
| 51 } // namespace webdriver |
| 52 #endif // CHROME_TEST_WEBDRIVER_SESSION_MANAGER_H_ |
| 53 |
OLD | NEW |