Extend envsetup.sh Clang hack to ASan builds.
[chromium-blink-merge.git] / net / socket_stream / socket_stream_job.cc
blob106656e5616b2a09101788e36b99f3a1df714e63
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
3 // found in the LICENSE file.
5 #include "net/socket_stream/socket_stream_job.h"
7 #include "base/memory/singleton.h"
8 #include "net/base/ssl_config_service.h"
9 #include "net/base/transport_security_state.h"
10 #include "net/socket_stream/socket_stream_job_manager.h"
11 #include "net/url_request/url_request_context.h"
13 namespace net {
15 // static
16 SocketStreamJob::ProtocolFactory* SocketStreamJob::RegisterProtocolFactory(
17 const std::string& scheme, ProtocolFactory* factory) {
18 return SocketStreamJobManager::GetInstance()->RegisterProtocolFactory(
19 scheme, factory);
22 // static
23 SocketStreamJob* SocketStreamJob::CreateSocketStreamJob(
24 const GURL& url,
25 SocketStream::Delegate* delegate,
26 TransportSecurityState* sts,
27 SSLConfigService* ssl) {
28 GURL socket_url(url);
29 TransportSecurityState::DomainState domain_state;
30 if (url.scheme() == "ws" && sts && sts->GetDomainState(
31 url.host(), SSLConfigService::IsSNIAvailable(ssl), &domain_state) &&
32 domain_state.ShouldRedirectHTTPToHTTPS()) {
33 url_canon::Replacements<char> replacements;
34 static const char kNewScheme[] = "wss";
35 replacements.SetScheme(kNewScheme,
36 url_parse::Component(0, strlen(kNewScheme)));
37 socket_url = url.ReplaceComponents(replacements);
39 return SocketStreamJobManager::GetInstance()->CreateJob(socket_url, delegate);
42 SocketStreamJob::SocketStreamJob() {}
44 SocketStream::UserData* SocketStreamJob::GetUserData(const void* key) const {
45 return socket_->GetUserData(key);
48 void SocketStreamJob::SetUserData(const void* key,
49 SocketStream::UserData* data) {
50 socket_->SetUserData(key, data);
53 void SocketStreamJob::Connect() {
54 socket_->Connect();
57 bool SocketStreamJob::SendData(const char* data, int len) {
58 return socket_->SendData(data, len);
61 void SocketStreamJob::Close() {
62 socket_->Close();
65 void SocketStreamJob::RestartWithAuth(const AuthCredentials& credentials) {
66 socket_->RestartWithAuth(credentials);
69 void SocketStreamJob::CancelWithError(int error) {
70 socket_->CancelWithError(error);
73 void SocketStreamJob::CancelWithSSLError(const net::SSLInfo& ssl_info) {
74 socket_->CancelWithSSLError(ssl_info);
77 void SocketStreamJob::ContinueDespiteError() {
78 socket_->ContinueDespiteError();
81 void SocketStreamJob::DetachDelegate() {
82 socket_->DetachDelegate();
85 SocketStreamJob::~SocketStreamJob() {}
87 } // namespace net