OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/socket_stream/socket_stream_job.h" | 5 #include "net/socket_stream/socket_stream_job.h" |
6 | 6 |
7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
8 #include "net/base/transport_security_state.h" | 8 #include "net/base/transport_security_state.h" |
9 #include "net/socket_stream/socket_stream_job_manager.h" | 9 #include "net/socket_stream/socket_stream_job_manager.h" |
10 #include "net/url_request/url_request_context.h" | 10 #include "net/url_request/url_request_context.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 // static | 14 // static |
15 SocketStreamJob::ProtocolFactory* SocketStreamJob::RegisterProtocolFactory( | 15 SocketStreamJob::ProtocolFactory* SocketStreamJob::RegisterProtocolFactory( |
16 const std::string& scheme, ProtocolFactory* factory) { | 16 const std::string& scheme, ProtocolFactory* factory) { |
17 return SocketStreamJobManager::GetInstance()->RegisterProtocolFactory( | 17 return SocketStreamJobManager::GetInstance()->RegisterProtocolFactory( |
18 scheme, factory); | 18 scheme, factory); |
19 } | 19 } |
20 | 20 |
21 // static | 21 // static |
22 SocketStreamJob* SocketStreamJob::CreateSocketStreamJob( | 22 SocketStreamJob* SocketStreamJob::CreateSocketStreamJob( |
23 const GURL& url, | 23 const GURL& url, |
24 SocketStream::Delegate* delegate, | 24 SocketStream::Delegate* delegate, |
25 const URLRequestContext& context) { | 25 TransportSecurityState* sts, |
26 SSLConfigService* ssl) { | |
26 GURL socket_url(url); | 27 GURL socket_url(url); |
27 TransportSecurityState::DomainState domain_state; | 28 TransportSecurityState::DomainState domain_state; |
28 if (url.scheme() == "ws" && | 29 if (url.scheme() == "ws" && sts && sts->IsEnabledForHost( |
29 context.transport_security_state() && | 30 &domain_state, url.host(), SSLConfigService::IsSNIAvailable(ssl)) && |
willchan no longer on Chromium
2011/05/05 18:00:35
please include ssl_config_service.h for this
Chris Evans
2011/05/05 22:00:56
Done.
| |
30 context.transport_security_state()->IsEnabledForHost( | |
31 &domain_state, url.host(), context.IsSNIAvailable()) && | |
32 domain_state.mode == TransportSecurityState::DomainState::MODE_STRICT) { | 31 domain_state.mode == TransportSecurityState::DomainState::MODE_STRICT) { |
33 url_canon::Replacements<char> replacements; | 32 url_canon::Replacements<char> replacements; |
34 static const char kNewScheme[] = "wss"; | 33 static const char kNewScheme[] = "wss"; |
35 replacements.SetScheme(kNewScheme, | 34 replacements.SetScheme(kNewScheme, |
36 url_parse::Component(0, strlen(kNewScheme))); | 35 url_parse::Component(0, strlen(kNewScheme))); |
37 socket_url = url.ReplaceComponents(replacements); | 36 socket_url = url.ReplaceComponents(replacements); |
38 } | 37 } |
39 return SocketStreamJobManager::GetInstance()->CreateJob(socket_url, delegate); | 38 return SocketStreamJobManager::GetInstance()->CreateJob(socket_url, delegate); |
40 } | 39 } |
41 | 40 |
(...skipping 25 matching lines...) Expand all Loading... | |
67 socket_->RestartWithAuth(username, password); | 66 socket_->RestartWithAuth(username, password); |
68 } | 67 } |
69 | 68 |
70 void SocketStreamJob::DetachDelegate() { | 69 void SocketStreamJob::DetachDelegate() { |
71 socket_->DetachDelegate(); | 70 socket_->DetachDelegate(); |
72 } | 71 } |
73 | 72 |
74 SocketStreamJob::~SocketStreamJob() {} | 73 SocketStreamJob::~SocketStreamJob() {} |
75 | 74 |
76 } // namespace net | 75 } // namespace net |
OLD | NEW |