| 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 #include "net/server/http_server.h" | 5 #include "net/server/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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 weak_ptr_factory_(this) { | 38 weak_ptr_factory_(this) { |
| 39 DCHECK(server_socket_); | 39 DCHECK(server_socket_); |
| 40 // Start accepting connections in next run loop in case when delegate is not | 40 // Start accepting connections in next run loop in case when delegate is not |
| 41 // ready to get callbacks. | 41 // ready to get callbacks. |
| 42 base::ThreadTaskRunnerHandle::Get()->PostTask( | 42 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 43 FROM_HERE, | 43 FROM_HERE, |
| 44 base::Bind(&HttpServer::DoAcceptLoop, weak_ptr_factory_.GetWeakPtr())); | 44 base::Bind(&HttpServer::DoAcceptLoop, weak_ptr_factory_.GetWeakPtr())); |
| 45 } | 45 } |
| 46 | 46 |
| 47 HttpServer::~HttpServer() { | 47 HttpServer::~HttpServer() { |
| 48 STLDeleteContainerPairSecondPointers( | 48 base::STLDeleteContainerPairSecondPointers(id_to_connection_.begin(), |
| 49 id_to_connection_.begin(), id_to_connection_.end()); | 49 id_to_connection_.end()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void HttpServer::AcceptWebSocket( | 52 void HttpServer::AcceptWebSocket( |
| 53 int connection_id, | 53 int connection_id, |
| 54 const HttpServerRequestInfo& request) { | 54 const HttpServerRequestInfo& request) { |
| 55 HttpConnection* connection = FindConnection(connection_id); | 55 HttpConnection* connection = FindConnection(connection_id); |
| 56 if (connection == NULL) | 56 if (connection == NULL) |
| 57 return; | 57 return; |
| 58 DCHECK(connection->web_socket()); | 58 DCHECK(connection->web_socket()); |
| 59 connection->web_socket()->Accept(request); | 59 connection->web_socket()->Accept(request); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 | 462 |
| 463 // 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() |
| 464 // has been called during callback processing. Using the pointer of connection, | 464 // has been called during callback processing. Using the pointer of connection, |
| 465 // |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 |
| 466 // loop. | 466 // loop. |
| 467 bool HttpServer::HasClosedConnection(HttpConnection* connection) { | 467 bool HttpServer::HasClosedConnection(HttpConnection* connection) { |
| 468 return FindConnection(connection->id()) != connection; | 468 return FindConnection(connection->id()) != connection; |
| 469 } | 469 } |
| 470 | 470 |
| 471 } // namespace net | 471 } // namespace net |
| OLD | NEW |