OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_TEST_WEBDRIVER_WEBDRIVER_SESSION_MANAGER_H_ | |
6 #define CHROME_TEST_WEBDRIVER_WEBDRIVER_SESSION_MANAGER_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "base/files/file_path.h" | |
12 #include "base/memory/singleton.h" | |
13 #include "base/synchronization/lock.h" | |
14 | |
15 namespace webdriver { | |
16 | |
17 class Session; | |
18 | |
19 // Session manager keeps track of all of the session that are currently | |
20 // running on the machine under test. With webdriver the user is allowed | |
21 // multiple instances of the browser on the same machine. So 2 sessions | |
22 // open would mean you would have 2 instances of chrome running under | |
23 // their own profiles. | |
24 class SessionManager { | |
25 public: | |
26 // Returns the singleton instance. | |
27 static SessionManager* GetInstance(); | |
28 | |
29 void Add(Session* session); | |
30 bool Remove(const std::string& id); | |
31 bool Has(const std::string& id) const; | |
32 | |
33 Session* GetSession(const std::string& id) const; | |
34 | |
35 void set_port(const std::string& port); | |
36 | |
37 void set_url_base(const std::string& url_base); | |
38 std::string url_base() const; | |
39 | |
40 private: | |
41 SessionManager(); | |
42 ~SessionManager(); | |
43 friend struct DefaultSingletonTraits<SessionManager>; | |
44 | |
45 std::map<std::string, Session*> map_; | |
46 mutable base::Lock map_lock_; | |
47 std::string port_; | |
48 std::string url_base_; | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(SessionManager); | |
51 }; | |
52 | |
53 } // namespace webdriver | |
54 | |
55 #endif // CHROME_TEST_WEBDRIVER_WEBDRIVER_SESSION_MANAGER_H_ | |
OLD | NEW |