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_connection.h" | 5 #include "net/server/http_connection.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "net/server/web_socket.h" | 10 #include "net/server/web_socket.h" |
9 #include "net/socket/stream_socket.h" | 11 #include "net/socket/stream_socket.h" |
10 | 12 |
11 namespace net { | 13 namespace net { |
12 | 14 |
13 HttpConnection::ReadIOBuffer::ReadIOBuffer() | 15 HttpConnection::ReadIOBuffer::ReadIOBuffer() |
14 : base_(new GrowableIOBuffer()), | 16 : base_(new GrowableIOBuffer()), |
15 max_buffer_size_(kDefaultMaxBufferSize) { | 17 max_buffer_size_(kDefaultMaxBufferSize) { |
16 SetCapacity(kInitialBufSize); | 18 SetCapacity(kInitialBufSize); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 return 0; | 145 return 0; |
144 } | 146 } |
145 DCHECK_GE(data_, pending_data_.front().data()); | 147 DCHECK_GE(data_, pending_data_.front().data()); |
146 int consumed = static_cast<int>(data_ - pending_data_.front().data()); | 148 int consumed = static_cast<int>(data_ - pending_data_.front().data()); |
147 DCHECK_GT(static_cast<int>(pending_data_.front().size()), consumed); | 149 DCHECK_GT(static_cast<int>(pending_data_.front().size()), consumed); |
148 return pending_data_.front().size() - consumed; | 150 return pending_data_.front().size() - consumed; |
149 } | 151 } |
150 | 152 |
151 HttpConnection::HttpConnection(int id, scoped_ptr<StreamSocket> socket) | 153 HttpConnection::HttpConnection(int id, scoped_ptr<StreamSocket> socket) |
152 : id_(id), | 154 : id_(id), |
153 socket_(socket.Pass()), | 155 socket_(std::move(socket)), |
154 read_buf_(new ReadIOBuffer()), | 156 read_buf_(new ReadIOBuffer()), |
155 write_buf_(new QueuedWriteIOBuffer()) { | 157 write_buf_(new QueuedWriteIOBuffer()) {} |
156 } | |
157 | 158 |
158 HttpConnection::~HttpConnection() { | 159 HttpConnection::~HttpConnection() { |
159 } | 160 } |
160 | 161 |
161 void HttpConnection::SetWebSocket(scoped_ptr<WebSocket> web_socket) { | 162 void HttpConnection::SetWebSocket(scoped_ptr<WebSocket> web_socket) { |
162 DCHECK(!web_socket_); | 163 DCHECK(!web_socket_); |
163 web_socket_ = web_socket.Pass(); | 164 web_socket_ = std::move(web_socket); |
164 } | 165 } |
165 | 166 |
166 } // namespace net | 167 } // namespace net |
OLD | NEW |