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

Side by Side Diff: net/websockets/websocket_job.cc

Issue 13990005: [SPDY] Replace SpdyIOBuffer with new SpdyBuffer class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix missing include Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « net/websockets/websocket_job.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
12 #include "net/base/io_buffer.h"
12 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
13 #include "net/base/net_log.h" 14 #include "net/base/net_log.h"
14 #include "net/cookies/cookie_store.h" 15 #include "net/cookies/cookie_store.h"
15 #include "net/base/io_buffer.h"
16 #include "net/http/http_network_session.h" 16 #include "net/http/http_network_session.h"
17 #include "net/http/http_transaction_factory.h" 17 #include "net/http/http_transaction_factory.h"
18 #include "net/http/http_util.h" 18 #include "net/http/http_util.h"
19 #include "net/spdy/spdy_session.h" 19 #include "net/spdy/spdy_session.h"
20 #include "net/spdy/spdy_session_pool.h" 20 #include "net/spdy/spdy_session_pool.h"
21 #include "net/url_request/url_request_context.h" 21 #include "net/url_request/url_request_context.h"
22 #include "net/websockets/websocket_handshake_handler.h" 22 #include "net/websockets/websocket_handshake_handler.h"
23 #include "net/websockets/websocket_net_log_params.h" 23 #include "net/websockets/websocket_net_log_params.h"
24 #include "net/websockets/websocket_throttle.h" 24 #include "net/websockets/websocket_throttle.h"
25 25
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 void WebSocketJob::OnSentSpdyData(size_t bytes_sent) { 323 void WebSocketJob::OnSentSpdyData(size_t bytes_sent) {
324 DCHECK_NE(INITIALIZED, state_); 324 DCHECK_NE(INITIALIZED, state_);
325 DCHECK_NE(CONNECTING, state_); 325 DCHECK_NE(CONNECTING, state_);
326 if (state_ == CLOSED) 326 if (state_ == CLOSED)
327 return; 327 return;
328 if (!spdy_websocket_stream_.get()) 328 if (!spdy_websocket_stream_.get())
329 return; 329 return;
330 OnSentData(socket_, static_cast<int>(bytes_sent)); 330 OnSentData(socket_, static_cast<int>(bytes_sent));
331 } 331 }
332 332
333 void WebSocketJob::OnReceivedSpdyData(const char* data, int length) { 333 void WebSocketJob::OnReceivedSpdyData(scoped_ptr<SpdyBuffer> buffer) {
334 DCHECK_NE(INITIALIZED, state_); 334 DCHECK_NE(INITIALIZED, state_);
335 DCHECK_NE(CONNECTING, state_); 335 DCHECK_NE(CONNECTING, state_);
336 if (state_ == CLOSED) 336 if (state_ == CLOSED)
337 return; 337 return;
338 if (!spdy_websocket_stream_.get()) 338 if (!spdy_websocket_stream_.get())
339 return; 339 return;
340 OnReceivedData(socket_, data, length); 340 if (buffer) {
341 OnReceivedData(socket_, buffer->GetRemainingData(),
342 buffer->GetRemainingSize());
343 } else {
344 OnReceivedData(socket_, NULL, 0);
345 }
341 } 346 }
342 347
343 void WebSocketJob::OnCloseSpdyStream() { 348 void WebSocketJob::OnCloseSpdyStream() {
344 spdy_websocket_stream_.reset(); 349 spdy_websocket_stream_.reset();
345 OnClose(socket_); 350 OnClose(socket_);
346 } 351 }
347 352
348 bool WebSocketJob::SendHandshakeRequest(const char* data, int len) { 353 bool WebSocketJob::SendHandshakeRequest(const char* data, int len) {
349 DCHECK_EQ(state_, CONNECTING); 354 DCHECK_EQ(state_, CONNECTING);
350 if (started_to_send_handshake_request_) 355 if (started_to_send_handshake_request_)
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 658
654 scoped_refptr<IOBufferWithSize> next_buffer = send_buffer_queue_.front(); 659 scoped_refptr<IOBufferWithSize> next_buffer = send_buffer_queue_.front();
655 send_buffer_queue_.pop_front(); 660 send_buffer_queue_.pop_front();
656 current_send_buffer_ = new DrainableIOBuffer(next_buffer, 661 current_send_buffer_ = new DrainableIOBuffer(next_buffer,
657 next_buffer->size()); 662 next_buffer->size());
658 SendDataInternal(current_send_buffer_->data(), 663 SendDataInternal(current_send_buffer_->data(),
659 current_send_buffer_->BytesRemaining()); 664 current_send_buffer_->BytesRemaining());
660 } 665 }
661 666
662 } // namespace net 667 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698