OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/spdy/spdy_proxy_client_socket.h" | 5 #include "net/spdy/spdy_proxy_client_socket.h" |
6 | 6 |
7 #include <algorithm> // min | 7 #include <algorithm> // min |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 397 |
398 OnIOComplete(status); | 398 OnIOComplete(status); |
399 | 399 |
400 return OK; | 400 return OK; |
401 } | 401 } |
402 | 402 |
403 // Called when data is received. | 403 // Called when data is received. |
404 void SpdyProxyClientSocket::OnDataReceived(const char* data, int length) { | 404 void SpdyProxyClientSocket::OnDataReceived(const char* data, int length) { |
405 if (length > 0) { | 405 if (length > 0) { |
406 // Save the received data. | 406 // Save the received data. |
407 scoped_refptr<IOBuffer> io_buffer = new IOBuffer(length); | 407 scoped_refptr<IOBuffer> io_buffer(new IOBuffer(length)); |
408 memcpy(io_buffer->data(), data, length); | 408 memcpy(io_buffer->data(), data, length); |
409 read_buffer_.push_back(new DrainableIOBuffer(io_buffer, length)); | 409 read_buffer_.push_back(new DrainableIOBuffer(io_buffer, length)); |
410 } | 410 } |
411 | 411 |
412 if (read_callback_) { | 412 if (read_callback_) { |
413 int rv = PopulateUserReadBuffer(); | 413 int rv = PopulateUserReadBuffer(); |
414 CompletionCallback* c = read_callback_; | 414 CompletionCallback* c = read_callback_; |
415 read_callback_ = NULL; | 415 read_callback_ = NULL; |
416 user_buffer_ = NULL; | 416 user_buffer_ = NULL; |
417 c->Run(rv); | 417 c->Run(rv); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 read_callback->Run(status); | 461 read_callback->Run(status); |
462 } else if (read_callback_) { | 462 } else if (read_callback_) { |
463 // If we have a read_callback, the we need to make sure we call it back | 463 // If we have a read_callback, the we need to make sure we call it back |
464 OnDataReceived(NULL, 0); | 464 OnDataReceived(NULL, 0); |
465 } | 465 } |
466 if (write_callback) | 466 if (write_callback) |
467 write_callback->Run(ERR_CONNECTION_CLOSED); | 467 write_callback->Run(ERR_CONNECTION_CLOSED); |
468 } | 468 } |
469 | 469 |
470 } // namespace net | 470 } // namespace net |
OLD | NEW |