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, ProtocolFactory* factory) { |
18 return SocketStreamJobManager::GetInstance()->RegisterProtocolFactory( | 18 return SocketStreamJobManager::GetInstance()->RegisterProtocolFactory( |
19 scheme, factory); | 19 scheme, factory); |
20 } | 20 } |
21 | 21 |
22 // static | 22 // static |
23 SocketStreamJob* SocketStreamJob::CreateSocketStreamJob( | 23 SocketStreamJob* SocketStreamJob::CreateSocketStreamJob( |
24 const GURL& url, | 24 const GURL& url, |
25 SocketStream::Delegate* delegate, | 25 SocketStream::Delegate* delegate, |
26 TransportSecurityState* sts, | 26 TransportSecurityState* sts, |
27 SSLConfigService* ssl) { | 27 SSLConfigService* ssl, |
| 28 URLRequestContext* context, |
| 29 CookieStore* cookie_store) { |
28 GURL socket_url(url); | 30 GURL socket_url(url); |
29 TransportSecurityState::DomainState domain_state; | 31 TransportSecurityState::DomainState domain_state; |
30 if (url.scheme() == "ws" && sts && sts->GetDomainState( | 32 if (url.scheme() == "ws" && sts && sts->GetDomainState( |
31 url.host(), SSLConfigService::IsSNIAvailable(ssl), &domain_state) && | 33 url.host(), SSLConfigService::IsSNIAvailable(ssl), &domain_state) && |
32 domain_state.ShouldUpgradeToSSL()) { | 34 domain_state.ShouldUpgradeToSSL()) { |
33 url_canon::Replacements<char> replacements; | 35 url_canon::Replacements<char> replacements; |
34 static const char kNewScheme[] = "wss"; | 36 static const char kNewScheme[] = "wss"; |
35 replacements.SetScheme(kNewScheme, | 37 replacements.SetScheme(kNewScheme, |
36 url_parse::Component(0, strlen(kNewScheme))); | 38 url_parse::Component(0, strlen(kNewScheme))); |
37 socket_url = url.ReplaceComponents(replacements); | 39 socket_url = url.ReplaceComponents(replacements); |
38 } | 40 } |
39 return SocketStreamJobManager::GetInstance()->CreateJob(socket_url, delegate); | 41 return SocketStreamJobManager::GetInstance()->CreateJob( |
| 42 socket_url, delegate, context, cookie_store); |
40 } | 43 } |
41 | 44 |
42 SocketStreamJob::SocketStreamJob() {} | 45 SocketStreamJob::SocketStreamJob() {} |
43 | 46 |
44 SocketStream::UserData* SocketStreamJob::GetUserData(const void* key) const { | 47 SocketStream::UserData* SocketStreamJob::GetUserData(const void* key) const { |
45 return socket_->GetUserData(key); | 48 return socket_->GetUserData(key); |
46 } | 49 } |
47 | 50 |
48 void SocketStreamJob::SetUserData(const void* key, | 51 void SocketStreamJob::SetUserData(const void* key, |
49 SocketStream::UserData* data) { | 52 SocketStream::UserData* data) { |
(...skipping 25 matching lines...) Expand all Loading... |
75 } | 78 } |
76 | 79 |
77 void SocketStreamJob::ContinueDespiteError() { | 80 void SocketStreamJob::ContinueDespiteError() { |
78 socket_->ContinueDespiteError(); | 81 socket_->ContinueDespiteError(); |
79 } | 82 } |
80 | 83 |
81 void SocketStreamJob::DetachDelegate() { | 84 void SocketStreamJob::DetachDelegate() { |
82 socket_->DetachDelegate(); | 85 socket_->DetachDelegate(); |
83 } | 86 } |
84 | 87 |
| 88 void SocketStreamJob::DetachContext() { |
| 89 if (socket_.get()) |
| 90 socket_->DetachContext(); |
| 91 } |
| 92 |
85 SocketStreamJob::~SocketStreamJob() {} | 93 SocketStreamJob::~SocketStreamJob() {} |
86 | 94 |
87 } // namespace net | 95 } // namespace net |
OLD | NEW |