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

Side by Side Diff: chrome/test/chromedriver/net/port_server.h

Issue 127143003: [chromedriver] Reuse forwarded adb ports. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_CHROMEDRIVER_NET_PORT_SERVER_H_ 5 #ifndef CHROME_TEST_CHROMEDRIVER_NET_PORT_SERVER_H_
6 #define CHROME_TEST_CHROMEDRIVER_NET_PORT_SERVER_H_ 6 #define CHROME_TEST_CHROMEDRIVER_NET_PORT_SERVER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 std::string path_; 44 std::string path_;
45 45
46 base::Lock free_lock_; 46 base::Lock free_lock_;
47 std::list<int> free_; 47 std::list<int> free_;
48 }; 48 };
49 49
50 // Manages reservation of a block of local ports. 50 // Manages reservation of a block of local ports.
51 class PortManager { 51 class PortManager {
52 public: 52 public:
53 PortManager(int min_port, int max_port); 53 // Since we cannot remove forwarded adb ports on older SDKs,
54 // maintain a pool of forwarded ports for reuse when |reuse| is true
55 PortManager(int min_port, int max_port, bool reuse);
54 ~PortManager(); 56 ~PortManager();
55 57
56 Status ReservePort(int* port, scoped_ptr<PortReservation>* reservation); 58 Status ReservePort(int* port, scoped_ptr<PortReservation>* reservation);
57 59
58 private: 60 private:
59 void ReleasePort(int port); 61 void ReleasePort(int port);
60 62
61 base::Lock taken_lock_; 63 base::Lock lock_;
62 std::set<int> taken_; 64 std::set<int> taken_;
63 65 std::list<int> unused_forwarded_port_;
64 int min_port_; 66 int min_port_;
65 int max_port_; 67 int max_port_;
68 bool reuse_;
66 }; 69 };
67 70
68 #endif // CHROME_TEST_CHROMEDRIVER_NET_PORT_SERVER_H_ 71 #endif // CHROME_TEST_CHROMEDRIVER_NET_PORT_SERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698