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/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/http/transport_security_state.h" | 8 #include "net/http/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/ssl/ssl_config_service.h" | 10 #include "net/ssl/ssl_config_service.h" |
11 #include "net/url_request/url_request_context.h" | 11 #include "net/url_request/url_request_context.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 // static | 15 // static |
16 SocketStreamJob::ProtocolFactory* SocketStreamJob::RegisterProtocolFactory( | 16 SocketStreamJob::ProtocolFactory* SocketStreamJob::RegisterProtocolFactory( |
17 const std::string& scheme, ProtocolFactory* factory) { | 17 const std::string& scheme, |
| 18 ProtocolFactory* factory) { |
18 return SocketStreamJobManager::GetInstance()->RegisterProtocolFactory( | 19 return SocketStreamJobManager::GetInstance()->RegisterProtocolFactory( |
19 scheme, factory); | 20 scheme, factory); |
20 } | 21 } |
21 | 22 |
22 // static | 23 // static |
23 SocketStreamJob* SocketStreamJob::CreateSocketStreamJob( | 24 SocketStreamJob* SocketStreamJob::CreateSocketStreamJob( |
24 const GURL& url, | 25 const GURL& url, |
25 SocketStream::Delegate* delegate, | 26 SocketStream::Delegate* delegate, |
26 TransportSecurityState* sts, | 27 TransportSecurityState* sts, |
27 SSLConfigService* ssl, | 28 SSLConfigService* ssl, |
28 URLRequestContext* context, | 29 URLRequestContext* context, |
29 CookieStore* cookie_store) { | 30 CookieStore* cookie_store) { |
30 GURL socket_url(url); | 31 GURL socket_url(url); |
31 TransportSecurityState::DomainState domain_state; | 32 TransportSecurityState::DomainState domain_state; |
32 if (url.scheme() == "ws" && sts && sts->GetDomainState( | 33 if (url.scheme() == "ws" && sts && |
| 34 sts->GetDomainState( |
33 url.host(), SSLConfigService::IsSNIAvailable(ssl), &domain_state) && | 35 url.host(), SSLConfigService::IsSNIAvailable(ssl), &domain_state) && |
34 domain_state.ShouldUpgradeToSSL()) { | 36 domain_state.ShouldUpgradeToSSL()) { |
35 url::Replacements<char> replacements; | 37 url::Replacements<char> replacements; |
36 static const char kNewScheme[] = "wss"; | 38 static const char kNewScheme[] = "wss"; |
37 replacements.SetScheme(kNewScheme, url::Component(0, strlen(kNewScheme))); | 39 replacements.SetScheme(kNewScheme, url::Component(0, strlen(kNewScheme))); |
38 socket_url = url.ReplaceComponents(replacements); | 40 socket_url = url.ReplaceComponents(replacements); |
39 } | 41 } |
40 return SocketStreamJobManager::GetInstance()->CreateJob( | 42 return SocketStreamJobManager::GetInstance()->CreateJob( |
41 socket_url, delegate, context, cookie_store); | 43 socket_url, delegate, context, cookie_store); |
42 } | 44 } |
43 | 45 |
44 SocketStreamJob::SocketStreamJob() {} | 46 SocketStreamJob::SocketStreamJob() { |
| 47 } |
45 | 48 |
46 SocketStream::UserData* SocketStreamJob::GetUserData(const void* key) const { | 49 SocketStream::UserData* SocketStreamJob::GetUserData(const void* key) const { |
47 return socket_->GetUserData(key); | 50 return socket_->GetUserData(key); |
48 } | 51 } |
49 | 52 |
50 void SocketStreamJob::SetUserData(const void* key, | 53 void SocketStreamJob::SetUserData(const void* key, |
51 SocketStream::UserData* data) { | 54 SocketStream::UserData* data) { |
52 socket_->SetUserData(key, data); | 55 socket_->SetUserData(key, data); |
53 } | 56 } |
54 | 57 |
(...skipping 27 matching lines...) Expand all Loading... |
82 | 85 |
83 void SocketStreamJob::DetachDelegate() { | 86 void SocketStreamJob::DetachDelegate() { |
84 socket_->DetachDelegate(); | 87 socket_->DetachDelegate(); |
85 } | 88 } |
86 | 89 |
87 void SocketStreamJob::DetachContext() { | 90 void SocketStreamJob::DetachContext() { |
88 if (socket_.get()) | 91 if (socket_.get()) |
89 socket_->DetachContext(); | 92 socket_->DetachContext(); |
90 } | 93 } |
91 | 94 |
92 SocketStreamJob::~SocketStreamJob() {} | 95 SocketStreamJob::~SocketStreamJob() { |
| 96 } |
93 | 97 |
94 } // namespace net | 98 } // namespace net |
OLD | NEW |