Add default implementations for AppWindowRegistry::Observer notifications.
[chromium-blink-merge.git] / net / socket_stream / socket_stream_job.cc
blob0bd702686bd7db13b437e04f0e73f1b9973911fc
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/http/transport_security_state.h"
9 #include "net/socket_stream/socket_stream_job_manager.h"
10 #include "net/ssl/ssl_config_service.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 URLRequestContext* context,
29 CookieStore* cookie_store) {
30 GURL socket_url(url);
31 TransportSecurityState::DomainState domain_state;
32 if (url.scheme() == "ws" && sts && sts->GetDomainState(
33 url.host(), SSLConfigService::IsSNIAvailable(ssl), &domain_state) &&
34 domain_state.ShouldUpgradeToSSL()) {
35 url::Replacements<char> replacements;
36 static const char kNewScheme[] = "wss";
37 replacements.SetScheme(kNewScheme, url::Component(0, strlen(kNewScheme)));
38 socket_url = url.ReplaceComponents(replacements);
40 return SocketStreamJobManager::GetInstance()->CreateJob(
41 socket_url, delegate, context, cookie_store);
44 SocketStreamJob::SocketStreamJob() {}
46 SocketStream::UserData* SocketStreamJob::GetUserData(const void* key) const {
47 return socket_->GetUserData(key);
50 void SocketStreamJob::SetUserData(const void* key,
51 SocketStream::UserData* data) {
52 socket_->SetUserData(key, data);
55 void SocketStreamJob::Connect() {
56 socket_->Connect();
59 bool SocketStreamJob::SendData(const char* data, int len) {
60 return socket_->SendData(data, len);
63 void SocketStreamJob::Close() {
64 socket_->Close();
67 void SocketStreamJob::RestartWithAuth(const AuthCredentials& credentials) {
68 socket_->RestartWithAuth(credentials);
71 void SocketStreamJob::CancelWithError(int error) {
72 socket_->CancelWithError(error);
75 void SocketStreamJob::CancelWithSSLError(const net::SSLInfo& ssl_info) {
76 socket_->CancelWithSSLError(ssl_info);
79 void SocketStreamJob::ContinueDespiteError() {
80 socket_->ContinueDespiteError();
83 void SocketStreamJob::DetachDelegate() {
84 socket_->DetachDelegate();
87 void SocketStreamJob::DetachContext() {
88 if (socket_.get())
89 socket_->DetachContext();
92 SocketStreamJob::~SocketStreamJob() {}
94 } // namespace net