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/websockets/websocket_job.h" | 5 #include "net/websockets/websocket_job.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 299 |
300 void WebSocketJob::OnSentSpdyHeaders() { | 300 void WebSocketJob::OnSentSpdyHeaders() { |
301 DCHECK_NE(INITIALIZED, state_); | 301 DCHECK_NE(INITIALIZED, state_); |
302 if (state_ != CONNECTING) | 302 if (state_ != CONNECTING) |
303 return; | 303 return; |
304 if (delegate_) | 304 if (delegate_) |
305 delegate_->OnSentData(socket_.get(), handshake_request_->original_length()); | 305 delegate_->OnSentData(socket_.get(), handshake_request_->original_length()); |
306 handshake_request_.reset(); | 306 handshake_request_.reset(); |
307 } | 307 } |
308 | 308 |
309 int WebSocketJob::OnReceivedSpdyResponseHeader( | 309 void WebSocketJob::OnSpdyResponseHeadersUpdated( |
310 const SpdyHeaderBlock& headers, int status) { | 310 const SpdyHeaderBlock& response_headers) { |
311 DCHECK_NE(INITIALIZED, state_); | 311 DCHECK_NE(INITIALIZED, state_); |
312 if (state_ != CONNECTING) | 312 if (state_ != CONNECTING) |
313 return status; | 313 return; |
314 if (status != OK) | |
315 return status; | |
316 // TODO(toyoshim): Fallback to non-spdy connection? | 314 // TODO(toyoshim): Fallback to non-spdy connection? |
317 handshake_response_->ParseResponseHeaderBlock(headers, | 315 handshake_response_->ParseResponseHeaderBlock(response_headers, |
318 challenge_, | 316 challenge_, |
319 spdy_protocol_version_); | 317 spdy_protocol_version_); |
320 | 318 |
321 SaveCookiesAndNotifyHeadersComplete(); | 319 SaveCookiesAndNotifyHeadersComplete(); |
322 return OK; | |
323 } | 320 } |
324 | 321 |
325 void WebSocketJob::OnSentSpdyData(size_t bytes_sent) { | 322 void WebSocketJob::OnSentSpdyData(size_t bytes_sent) { |
326 DCHECK_NE(INITIALIZED, state_); | 323 DCHECK_NE(INITIALIZED, state_); |
327 DCHECK_NE(CONNECTING, state_); | 324 DCHECK_NE(CONNECTING, state_); |
328 if (state_ == CLOSED) | 325 if (state_ == CLOSED) |
329 return; | 326 return; |
330 if (!spdy_websocket_stream_.get()) | 327 if (!spdy_websocket_stream_.get()) |
331 return; | 328 return; |
332 OnSentData(socket_.get(), static_cast<int>(bytes_sent)); | 329 OnSentData(socket_.get(), static_cast<int>(bytes_sent)); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 | 695 |
699 scoped_refptr<IOBufferWithSize> next_buffer = send_buffer_queue_.front(); | 696 scoped_refptr<IOBufferWithSize> next_buffer = send_buffer_queue_.front(); |
700 send_buffer_queue_.pop_front(); | 697 send_buffer_queue_.pop_front(); |
701 current_send_buffer_ = | 698 current_send_buffer_ = |
702 new DrainableIOBuffer(next_buffer.get(), next_buffer->size()); | 699 new DrainableIOBuffer(next_buffer.get(), next_buffer->size()); |
703 SendDataInternal(current_send_buffer_->data(), | 700 SendDataInternal(current_send_buffer_->data(), |
704 current_send_buffer_->BytesRemaining()); | 701 current_send_buffer_->BytesRemaining()); |
705 } | 702 } |
706 | 703 |
707 } // namespace net | 704 } // namespace net |
OLD | NEW |