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

Side by Side Diff: mojo/services/network/http_server_impl.cc

Issue 1139673003: Make Mandoline shut down cleanly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mojo/services/network/http_server_impl.h" 5 #include "mojo/services/network/http_server_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/services/network/http_connection_impl.h" 8 #include "mojo/services/network/http_connection_impl.h"
9 #include "mojo/services/network/net_adapters.h" 9 #include "mojo/services/network/net_adapters.h"
10 #include "mojo/services/network/net_address_type_converters.h" 10 #include "mojo/services/network/net_address_type_converters.h"
11 #include "net/base/ip_endpoint.h" 11 #include "net/base/ip_endpoint.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/log/net_log.h" 13 #include "net/log/net_log.h"
14 #include "net/socket/tcp_server_socket.h" 14 #include "net/socket/tcp_server_socket.h"
15 15
16 namespace mojo { 16 namespace mojo {
17 17
18 namespace { 18 namespace {
19 19
20 const int kBackLog = 10; 20 const int kBackLog = 10;
21 21
22 } // namespace 22 } // namespace
23 23
24 // static 24 // static
25 void HttpServerImpl::Create( 25 void HttpServerImpl::Create(
26 NetAddressPtr local_address, 26 NetAddressPtr local_address,
27 HttpServerDelegatePtr delegate, 27 HttpServerDelegatePtr delegate,
28 scoped_ptr<mojo::AppRefCount> app_refcount,
28 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback) { 29 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback) {
29 HttpServerImpl* http_server = new HttpServerImpl(delegate.Pass()); 30 HttpServerImpl* http_server = new HttpServerImpl(
31 delegate.Pass(), app_refcount.Pass());
30 32
31 int net_error = http_server->Start(local_address.Pass()); 33 int net_error = http_server->Start(local_address.Pass());
32 if (net_error != net::OK) { 34 if (net_error != net::OK) {
33 callback.Run(MakeNetworkError(net_error), nullptr); 35 callback.Run(MakeNetworkError(net_error), nullptr);
34 delete http_server; 36 delete http_server;
35 return; 37 return;
36 } 38 }
37 callback.Run(MakeNetworkError(net::OK), http_server->GetLocalAddress()); 39 callback.Run(MakeNetworkError(net::OK), http_server->GetLocalAddress());
38 } 40 }
39 41
40 HttpServerImpl::HttpServerImpl(HttpServerDelegatePtr delegate) 42 HttpServerImpl::HttpServerImpl(
41 : delegate_(delegate.Pass()) { 43 HttpServerDelegatePtr delegate,
44 scoped_ptr<mojo::AppRefCount> app_refcount)
45 : delegate_(delegate.Pass()), app_refcount_(app_refcount.Pass()) {
42 DCHECK(delegate_); 46 DCHECK(delegate_);
43 delegate_.set_error_handler(this); 47 delegate_.set_error_handler(this);
44 } 48 }
45 49
46 HttpServerImpl::~HttpServerImpl() {} 50 HttpServerImpl::~HttpServerImpl() {}
47 51
48 int HttpServerImpl::Start(NetAddressPtr local_address) { 52 int HttpServerImpl::Start(NetAddressPtr local_address) {
49 DCHECK(local_address); 53 DCHECK(local_address);
50 54
51 scoped_ptr<net::ServerSocket> socket( 55 scoped_ptr<net::ServerSocket> socket(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void HttpServerImpl::OnClose(int connection_id) { 114 void HttpServerImpl::OnClose(int connection_id) {
111 DCHECK(connections_.find(connection_id) != connections_.end()); 115 DCHECK(connections_.find(connection_id) != connections_.end());
112 connections_.erase(connection_id); 116 connections_.erase(connection_id);
113 } 117 }
114 118
115 void HttpServerImpl::OnConnectionError() { 119 void HttpServerImpl::OnConnectionError() {
116 delete this; 120 delete this;
117 } 121 }
118 122
119 } // namespace mojo 123 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/network/http_server_impl.h ('k') | mojo/services/network/network_service_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698