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

Side by Side Diff: chrome/test/webdriver/session_manager.h

Issue 6507015: Implement the target locator commands for ChromeDriver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use bool success instead of handle != 0 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #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"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "chrome/test/webdriver/session.h" 13 #include "chrome/test/webdriver/session.h"
14 14
15 namespace webdriver { 15 namespace webdriver {
16 16
17 // Session manager keeps track of all of the session that are currently 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 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 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 20 // open would mean you would have 2 instances of chrome running under
21 // their own profiles. 21 // their own profiles.
22 class SessionManager { 22 class SessionManager {
23 public: 23 public:
24 // Returns the singleton instance. 24 // Returns the singleton instance.
25 static SessionManager* GetInstance(); 25 static SessionManager* GetInstance();
26 26
27 std::string GetAddress(); 27 std::string GetAddress();
28 28
29 Session* Create(); 29 void Add(Session* session);
30 bool Delete(const std::string& id); 30 bool Remove(const std::string& id);
31 bool Has(const std::string& id) const; 31 bool Has(const std::string& id) const;
32 32
33 Session* GetSession(const std::string& id) const; 33 Session* GetSession(const std::string& id) const;
34 34
35 void set_port(const std::string& port) { port_ = port; } 35 void set_port(const std::string& port) { port_ = port; }
36 36
37 private: 37 private:
38 SessionManager(); 38 SessionManager();
39 ~SessionManager(); 39 ~SessionManager();
40 friend struct DefaultSingletonTraits<SessionManager>; 40 friend struct DefaultSingletonTraits<SessionManager>;
41 41
42 std::map<std::string, Session*> map_; 42 std::map<std::string, Session*> map_;
43 mutable base::Lock map_lock_; 43 mutable base::Lock map_lock_;
44 std::string port_; 44 std::string port_;
45 45
46 DISALLOW_COPY_AND_ASSIGN(SessionManager); 46 DISALLOW_COPY_AND_ASSIGN(SessionManager);
47 }; 47 };
48 48
49 } // namespace webdriver 49 } // namespace webdriver
50 50
51 #endif // CHROME_TEST_WEBDRIVER_SESSION_MANAGER_H_ 51 #endif // CHROME_TEST_WEBDRIVER_SESSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698