| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 NET_TEST_SPAWNED_TEST_SERVER_SPAWNER_COMMUNICATOR_H_ | 5 #ifndef NET_TEST_SPAWNED_TEST_SERVER_SPAWNER_COMMUNICATOR_H_ |
| 6 #define NET_TEST_SPAWNED_TEST_SERVER_SPAWNER_COMMUNICATOR_H_ | 6 #define NET_TEST_SPAWNED_TEST_SERVER_SPAWNER_COMMUNICATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 17 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
| 18 | 18 |
| 19 namespace net { | 19 namespace net { |
| 20 | 20 |
| 21 class ScopedPortException; | 21 class ScopedPortException; |
| 22 | 22 |
| 23 // SpawnerCommunicator communicates with a spawner server that runs on a | 23 // SpawnerCommunicator communicates with a spawner server that runs on a |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // WaitableEvent to notify whether the communication is done. | 120 // WaitableEvent to notify whether the communication is done. |
| 121 base::WaitableEvent event_; | 121 base::WaitableEvent event_; |
| 122 | 122 |
| 123 // The local port used to communicate with the TestServer spawner. This is | 123 // The local port used to communicate with the TestServer spawner. This is |
| 124 // used to control the startup and shutdown of the Python TestServer running | 124 // used to control the startup and shutdown of the Python TestServer running |
| 125 // on the remote machine. On Android, this port will be redirected to the | 125 // on the remote machine. On Android, this port will be redirected to the |
| 126 // same port on the host machine. | 126 // same port on the host machine. |
| 127 const uint16_t port_; | 127 const uint16_t port_; |
| 128 | 128 |
| 129 // Helper to add |port_| to the list of the globally explicitly allowed ports. | 129 // Helper to add |port_| to the list of the globally explicitly allowed ports. |
| 130 scoped_ptr<ScopedPortException> allowed_port_; | 130 std::unique_ptr<ScopedPortException> allowed_port_; |
| 131 | 131 |
| 132 // The next ID to use for |cur_request_| (monotonically increasing). | 132 // The next ID to use for |cur_request_| (monotonically increasing). |
| 133 int next_id_; | 133 int next_id_; |
| 134 | 134 |
| 135 // Request context used by |cur_request_|. | 135 // Request context used by |cur_request_|. |
| 136 scoped_ptr<URLRequestContext> context_; | 136 std::unique_ptr<URLRequestContext> context_; |
| 137 | 137 |
| 138 // The current (in progress) request, or NULL. | 138 // The current (in progress) request, or NULL. |
| 139 scoped_ptr<URLRequest> cur_request_; | 139 std::unique_ptr<URLRequest> cur_request_; |
| 140 | 140 |
| 141 // Only gets/sets |is_running_| on user's thread to avoid race-condition. | 141 // Only gets/sets |is_running_| on user's thread to avoid race-condition. |
| 142 bool is_running_; | 142 bool is_running_; |
| 143 | 143 |
| 144 // Factory for creating the time-out task. This takes care of revoking | 144 // Factory for creating the time-out task. This takes care of revoking |
| 145 // outstanding tasks when |this| is deleted. | 145 // outstanding tasks when |this| is deleted. |
| 146 base::WeakPtrFactory<SpawnerCommunicator> weak_factory_; | 146 base::WeakPtrFactory<SpawnerCommunicator> weak_factory_; |
| 147 | 147 |
| 148 DISALLOW_COPY_AND_ASSIGN(SpawnerCommunicator); | 148 DISALLOW_COPY_AND_ASSIGN(SpawnerCommunicator); |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 } // namespace net | 151 } // namespace net |
| 152 | 152 |
| 153 #endif // NET_TEST_SPAWNED_TEST_SERVER_SPAWNER_COMMUNICATOR_H_ | 153 #endif // NET_TEST_SPAWNED_TEST_SERVER_SPAWNER_COMMUNICATOR_H_ |
| OLD | NEW |