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

Side by Side Diff: net/server/http_server.cc

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « net/server/http_connection.cc ('k') | net/server/http_server_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "net/server/http_server.h" 5 #include "net/server/http_server.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
9 #include "base/location.h" 11 #include "base/location.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
11 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
12 #include "base/stl_util.h" 14 #include "base/stl_util.h"
13 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
16 #include "base/sys_byteorder.h" 18 #include "base/sys_byteorder.h"
17 #include "base/thread_task_runner_handle.h" 19 #include "base/thread_task_runner_handle.h"
18 #include "build/build_config.h" 20 #include "build/build_config.h"
19 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
20 #include "net/server/http_connection.h" 22 #include "net/server/http_connection.h"
21 #include "net/server/http_server_request_info.h" 23 #include "net/server/http_server_request_info.h"
22 #include "net/server/http_server_response_info.h" 24 #include "net/server/http_server_response_info.h"
23 #include "net/server/web_socket.h" 25 #include "net/server/web_socket.h"
24 #include "net/socket/server_socket.h" 26 #include "net/socket/server_socket.h"
25 #include "net/socket/stream_socket.h" 27 #include "net/socket/stream_socket.h"
26 #include "net/socket/tcp_server_socket.h" 28 #include "net/socket/tcp_server_socket.h"
27 29
28 namespace net { 30 namespace net {
29 31
30 HttpServer::HttpServer(scoped_ptr<ServerSocket> server_socket, 32 HttpServer::HttpServer(scoped_ptr<ServerSocket> server_socket,
31 HttpServer::Delegate* delegate) 33 HttpServer::Delegate* delegate)
32 : server_socket_(server_socket.Pass()), 34 : server_socket_(std::move(server_socket)),
33 delegate_(delegate), 35 delegate_(delegate),
34 last_id_(0), 36 last_id_(0),
35 weak_ptr_factory_(this) { 37 weak_ptr_factory_(this) {
36 DCHECK(server_socket_); 38 DCHECK(server_socket_);
37 // Start accepting connections in next run loop in case when delegate is not 39 // Start accepting connections in next run loop in case when delegate is not
38 // ready to get callbacks. 40 // ready to get callbacks.
39 base::ThreadTaskRunnerHandle::Get()->PostTask( 41 base::ThreadTaskRunnerHandle::Get()->PostTask(
40 FROM_HERE, 42 FROM_HERE,
41 base::Bind(&HttpServer::DoAcceptLoop, weak_ptr_factory_.GetWeakPtr())); 43 base::Bind(&HttpServer::DoAcceptLoop, weak_ptr_factory_.GetWeakPtr()));
42 } 44 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 DoAcceptLoop(); 154 DoAcceptLoop();
153 } 155 }
154 156
155 int HttpServer::HandleAcceptResult(int rv) { 157 int HttpServer::HandleAcceptResult(int rv) {
156 if (rv < 0) { 158 if (rv < 0) {
157 LOG(ERROR) << "Accept error: rv=" << rv; 159 LOG(ERROR) << "Accept error: rv=" << rv;
158 return rv; 160 return rv;
159 } 161 }
160 162
161 HttpConnection* connection = 163 HttpConnection* connection =
162 new HttpConnection(++last_id_, accepted_socket_.Pass()); 164 new HttpConnection(++last_id_, std::move(accepted_socket_));
163 id_to_connection_[connection->id()] = connection; 165 id_to_connection_[connection->id()] = connection;
164 delegate_->OnConnect(connection->id()); 166 delegate_->OnConnect(connection->id());
165 if (!HasClosedConnection(connection)) 167 if (!HasClosedConnection(connection))
166 DoReadLoop(connection); 168 DoReadLoop(connection);
167 return OK; 169 return OK;
168 } 170 }
169 171
170 void HttpServer::DoReadLoop(HttpConnection* connection) { 172 void HttpServer::DoReadLoop(HttpConnection* connection) {
171 int rv; 173 int rv;
172 do { 174 do {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 461
460 // This is called after any delegate callbacks are called to check if Close() 462 // This is called after any delegate callbacks are called to check if Close()
461 // has been called during callback processing. Using the pointer of connection, 463 // has been called during callback processing. Using the pointer of connection,
462 // |connection| is safe here because Close() deletes the connection in next run 464 // |connection| is safe here because Close() deletes the connection in next run
463 // loop. 465 // loop.
464 bool HttpServer::HasClosedConnection(HttpConnection* connection) { 466 bool HttpServer::HasClosedConnection(HttpConnection* connection) {
465 return FindConnection(connection->id()) != connection; 467 return FindConnection(connection->id()) != connection;
466 } 468 }
467 469
468 } // namespace net 470 } // namespace net
OLDNEW
« no previous file with comments | « net/server/http_connection.cc ('k') | net/server/http_server_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698