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

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

Issue 295383007: Get rid of websocket_over_spdy_enabled global. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with fixed linebreaks Created 6 years, 6 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') | net/websockets/websocket_job_test.cc » ('j') | 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"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 }; 53 };
54 54
55 static base::LazyInstance<WebSocketJobInitSingleton> g_websocket_job_init = 55 static base::LazyInstance<WebSocketJobInitSingleton> g_websocket_job_init =
56 LAZY_INSTANCE_INITIALIZER; 56 LAZY_INSTANCE_INITIALIZER;
57 57
58 } // anonymous namespace 58 } // anonymous namespace
59 59
60 namespace net { 60 namespace net {
61 61
62 bool WebSocketJob::websocket_over_spdy_enabled_ = false;
63
64 // static 62 // static
65 void WebSocketJob::EnsureInit() { 63 void WebSocketJob::EnsureInit() {
66 g_websocket_job_init.Get(); 64 g_websocket_job_init.Get();
67 } 65 }
68 66
69 // static
70 void WebSocketJob::set_websocket_over_spdy_enabled(bool enabled) {
71 websocket_over_spdy_enabled_ = enabled;
72 }
73
74 WebSocketJob::WebSocketJob(SocketStream::Delegate* delegate) 67 WebSocketJob::WebSocketJob(SocketStream::Delegate* delegate)
75 : delegate_(delegate), 68 : delegate_(delegate),
76 state_(INITIALIZED), 69 state_(INITIALIZED),
77 waiting_(false), 70 waiting_(false),
78 handshake_request_(new WebSocketHandshakeRequestHandler), 71 handshake_request_(new WebSocketHandshakeRequestHandler),
79 handshake_response_(new WebSocketHandshakeResponseHandler), 72 handshake_response_(new WebSocketHandshakeResponseHandler),
80 started_to_send_handshake_request_(false), 73 started_to_send_handshake_request_(false),
81 handshake_request_sent_(0), 74 handshake_request_sent_(0),
82 response_cookies_save_index_(0), 75 response_cookies_save_index_(0),
83 spdy_protocol_version_(0), 76 spdy_protocol_version_(0),
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 } 565 }
573 566
574 const AddressList& WebSocketJob::address_list() const { 567 const AddressList& WebSocketJob::address_list() const {
575 return addresses_; 568 return addresses_;
576 } 569 }
577 570
578 int WebSocketJob::TrySpdyStream() { 571 int WebSocketJob::TrySpdyStream() {
579 if (!socket_.get()) 572 if (!socket_.get())
580 return ERR_FAILED; 573 return ERR_FAILED;
581 574
582 if (!websocket_over_spdy_enabled_)
583 return OK;
584
585 // Check if we have a SPDY session available. 575 // Check if we have a SPDY session available.
586 HttpTransactionFactory* factory = 576 HttpTransactionFactory* factory =
587 socket_->context()->http_transaction_factory(); 577 socket_->context()->http_transaction_factory();
588 if (!factory) 578 if (!factory)
589 return OK; 579 return OK;
590 scoped_refptr<HttpNetworkSession> session = factory->GetSession(); 580 scoped_refptr<HttpNetworkSession> session = factory->GetSession();
591 if (!session.get()) 581 if (!session.get() || !session->params().enable_websocket_over_spdy)
592 return OK; 582 return OK;
593 SpdySessionPool* spdy_pool = session->spdy_session_pool(); 583 SpdySessionPool* spdy_pool = session->spdy_session_pool();
594 PrivacyMode privacy_mode = socket_->privacy_mode(); 584 PrivacyMode privacy_mode = socket_->privacy_mode();
595 const SpdySessionKey key(HostPortPair::FromURL(socket_->url()), 585 const SpdySessionKey key(HostPortPair::FromURL(socket_->url()),
596 socket_->proxy_server(), privacy_mode); 586 socket_->proxy_server(), privacy_mode);
597 // Forbid wss downgrade to SPDY without SSL. 587 // Forbid wss downgrade to SPDY without SSL.
598 // TODO(toyoshim): Does it realize the same policy with HTTP? 588 // TODO(toyoshim): Does it realize the same policy with HTTP?
599 base::WeakPtr<SpdySession> spdy_session = 589 base::WeakPtr<SpdySession> spdy_session =
600 spdy_pool->FindAvailableSession(key, *socket_->net_log()); 590 spdy_pool->FindAvailableSession(key, *socket_->net_log());
601 if (!spdy_session) 591 if (!spdy_session)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 684
695 scoped_refptr<IOBufferWithSize> next_buffer = send_buffer_queue_.front(); 685 scoped_refptr<IOBufferWithSize> next_buffer = send_buffer_queue_.front();
696 send_buffer_queue_.pop_front(); 686 send_buffer_queue_.pop_front();
697 current_send_buffer_ = 687 current_send_buffer_ =
698 new DrainableIOBuffer(next_buffer.get(), next_buffer->size()); 688 new DrainableIOBuffer(next_buffer.get(), next_buffer->size());
699 SendDataInternal(current_send_buffer_->data(), 689 SendDataInternal(current_send_buffer_->data(),
700 current_send_buffer_->BytesRemaining()); 690 current_send_buffer_->BytesRemaining());
701 } 691 }
702 692
703 } // namespace net 693 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_job.h ('k') | net/websockets/websocket_job_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698