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

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

Issue 668053003: Finish gracefully on stop events, but not on pause events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « no previous file | no next file » | 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 "base/bind.h"
7 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/location.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/stl_util.h" 12 #include "base/stl_util.h"
10 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
13 #include "base/sys_byteorder.h" 16 #include "base/sys_byteorder.h"
14 #include "build/build_config.h" 17 #include "build/build_config.h"
15 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
16 #include "net/server/http_connection.h" 19 #include "net/server/http_connection.h"
17 #include "net/server/http_server_request_info.h" 20 #include "net/server/http_server_request_info.h"
18 #include "net/server/http_server_response_info.h" 21 #include "net/server/http_server_response_info.h"
19 #include "net/server/web_socket.h" 22 #include "net/server/web_socket.h"
20 #include "net/socket/server_socket.h" 23 #include "net/socket/server_socket.h"
21 #include "net/socket/stream_socket.h" 24 #include "net/socket/stream_socket.h"
22 #include "net/socket/tcp_server_socket.h" 25 #include "net/socket/tcp_server_socket.h"
23 26
24 namespace net { 27 namespace net {
25 28
26 HttpServer::HttpServer(scoped_ptr<ServerSocket> server_socket, 29 HttpServer::HttpServer(scoped_ptr<ServerSocket> server_socket,
27 HttpServer::Delegate* delegate) 30 HttpServer::Delegate* delegate)
28 : server_socket_(server_socket.Pass()), 31 : server_socket_(server_socket.Pass()),
29 delegate_(delegate), 32 delegate_(delegate),
30 last_id_(0), 33 last_id_(0),
31 weak_ptr_factory_(this) { 34 weak_ptr_factory_(this) {
32 DCHECK(server_socket_); 35 DCHECK(server_socket_);
33 DoAcceptLoop(); 36 // Start accepting connections in next run loop in case when delegate is not
37 // ready to get callbacks.
38 base::MessageLoopProxy::current()->PostTask(
39 FROM_HERE,
40 base::Bind(&HttpServer::DoAcceptLoop, weak_ptr_factory_.GetWeakPtr()));
34 } 41 }
35 42
36 HttpServer::~HttpServer() { 43 HttpServer::~HttpServer() {
37 STLDeleteContainerPairSecondPointers( 44 STLDeleteContainerPairSecondPointers(
38 id_to_connection_.begin(), id_to_connection_.end()); 45 id_to_connection_.begin(), id_to_connection_.end());
39 } 46 }
40 47
41 void HttpServer::AcceptWebSocket( 48 void HttpServer::AcceptWebSocket(
42 int connection_id, 49 int connection_id,
43 const HttpServerRequestInfo& request) { 50 const HttpServerRequestInfo& request) {
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 462
456 // This is called after any delegate callbacks are called to check if Close() 463 // This is called after any delegate callbacks are called to check if Close()
457 // has been called during callback processing. Using the pointer of connection, 464 // has been called during callback processing. Using the pointer of connection,
458 // |connection| is safe here because Close() deletes the connection in next run 465 // |connection| is safe here because Close() deletes the connection in next run
459 // loop. 466 // loop.
460 bool HttpServer::HasClosedConnection(HttpConnection* connection) { 467 bool HttpServer::HasClosedConnection(HttpConnection* connection) {
461 return FindConnection(connection->id()) != connection; 468 return FindConnection(connection->id()) != connection;
462 } 469 }
463 470
464 } // namespace net 471 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698