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

Side by Side Diff: chrome/test/chromedriver/net/test_http_server.cc

Issue 2333923004: Extracting NetLog inner classes into their own classes. (Closed)
Patch Set: Some nit fixes and better, impl-agnostic naming of net_log_parameters_callback_typedef.h -> net/log… Created 4 years, 2 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
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 #include "chrome/test/chromedriver/net/test_http_server.h" 5 #include "chrome/test/chromedriver/net/test_http_server.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "net/base/ip_endpoint.h" 16 #include "net/base/ip_endpoint.h"
17 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
18 #include "net/log/net_log_source.h"
18 #include "net/server/http_server_request_info.h" 19 #include "net/server/http_server_request_info.h"
19 #include "net/socket/tcp_server_socket.h" 20 #include "net/socket/tcp_server_socket.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 const int kBufferSize = 100 * 1024 * 1024; // 100 MB 23 const int kBufferSize = 100 * 1024 * 1024; // 100 MB
23 24
24 TestHttpServer::TestHttpServer() 25 TestHttpServer::TestHttpServer()
25 : thread_("ServerThread"), 26 : thread_("ServerThread"),
26 all_closed_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, 27 all_closed_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
27 base::WaitableEvent::InitialState::SIGNALED), 28 base::WaitableEvent::InitialState::SIGNALED),
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 136
136 void TestHttpServer::OnClose(int connection_id) { 137 void TestHttpServer::OnClose(int connection_id) {
137 connections_.erase(connection_id); 138 connections_.erase(connection_id);
138 if (connections_.empty()) 139 if (connections_.empty())
139 all_closed_event_.Signal(); 140 all_closed_event_.Signal();
140 } 141 }
141 142
142 void TestHttpServer::StartOnServerThread(bool* success, 143 void TestHttpServer::StartOnServerThread(bool* success,
143 base::WaitableEvent* event) { 144 base::WaitableEvent* event) {
144 std::unique_ptr<net::ServerSocket> server_socket( 145 std::unique_ptr<net::ServerSocket> server_socket(
145 new net::TCPServerSocket(NULL, net::NetLog::Source())); 146 new net::TCPServerSocket(NULL, net::NetLogSource()));
146 server_socket->ListenWithAddressAndPort("127.0.0.1", 0, 1); 147 server_socket->ListenWithAddressAndPort("127.0.0.1", 0, 1);
147 server_.reset(new net::HttpServer(std::move(server_socket), this)); 148 server_.reset(new net::HttpServer(std::move(server_socket), this));
148 149
149 net::IPEndPoint address; 150 net::IPEndPoint address;
150 int error = server_->GetLocalAddress(&address); 151 int error = server_->GetLocalAddress(&address);
151 EXPECT_EQ(net::OK, error); 152 EXPECT_EQ(net::OK, error);
152 if (error == net::OK) { 153 if (error == net::OK) {
153 base::AutoLock lock(url_lock_); 154 base::AutoLock lock(url_lock_);
154 web_socket_url_ = GURL(base::StringPrintf("ws://127.0.0.1:%d", 155 web_socket_url_ = GURL(base::StringPrintf("ws://127.0.0.1:%d",
155 address.port())); 156 address.port()));
156 } else { 157 } else {
157 server_.reset(NULL); 158 server_.reset(NULL);
158 } 159 }
159 *success = server_.get(); 160 *success = server_.get();
160 event->Signal(); 161 event->Signal();
161 } 162 }
162 163
163 void TestHttpServer::StopOnServerThread(base::WaitableEvent* event) { 164 void TestHttpServer::StopOnServerThread(base::WaitableEvent* event) {
164 server_.reset(NULL); 165 server_.reset(NULL);
165 event->Signal(); 166 event->Signal();
166 } 167 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698