| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/shell/browser/url_request_context_factory.h" | 5 #include "chromecast/shell/browser/url_request_context_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // The URLRequestContextFactory::URLRequestContextGetter class is used for both | 52 // The URLRequestContextFactory::URLRequestContextGetter class is used for both |
| 53 // the system and media URLRequestCotnexts. | 53 // the system and media URLRequestCotnexts. |
| 54 class URLRequestContextFactory::URLRequestContextGetter | 54 class URLRequestContextFactory::URLRequestContextGetter |
| 55 : public net::URLRequestContextGetter { | 55 : public net::URLRequestContextGetter { |
| 56 public: | 56 public: |
| 57 URLRequestContextGetter(URLRequestContextFactory* factory, bool is_media) | 57 URLRequestContextGetter(URLRequestContextFactory* factory, bool is_media) |
| 58 : is_media_(is_media), | 58 : is_media_(is_media), |
| 59 factory_(factory) { | 59 factory_(factory) { |
| 60 } | 60 } |
| 61 | 61 |
| 62 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE { | 62 virtual net::URLRequestContext* GetURLRequestContext() override { |
| 63 if (!request_context_) { | 63 if (!request_context_) { |
| 64 if (is_media_) { | 64 if (is_media_) { |
| 65 request_context_.reset(factory_->CreateMediaRequestContext()); | 65 request_context_.reset(factory_->CreateMediaRequestContext()); |
| 66 } else { | 66 } else { |
| 67 request_context_.reset(factory_->CreateSystemRequestContext()); | 67 request_context_.reset(factory_->CreateSystemRequestContext()); |
| 68 #if defined(USE_NSS) | 68 #if defined(USE_NSS) |
| 69 // Set request context used by NSS for Crl requests. | 69 // Set request context used by NSS for Crl requests. |
| 70 net::SetURLRequestContextForNSSHttpIO(request_context_.get()); | 70 net::SetURLRequestContextForNSSHttpIO(request_context_.get()); |
| 71 #endif // defined(USE_NSS) | 71 #endif // defined(USE_NSS) |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 return request_context_.get(); | 74 return request_context_.get(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 virtual scoped_refptr<base::SingleThreadTaskRunner> | 77 virtual scoped_refptr<base::SingleThreadTaskRunner> |
| 78 GetNetworkTaskRunner() const OVERRIDE { | 78 GetNetworkTaskRunner() const override { |
| 79 return content::BrowserThread::GetMessageLoopProxyForThread( | 79 return content::BrowserThread::GetMessageLoopProxyForThread( |
| 80 content::BrowserThread::IO); | 80 content::BrowserThread::IO); |
| 81 } | 81 } |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 virtual ~URLRequestContextGetter() {} | 84 virtual ~URLRequestContextGetter() {} |
| 85 | 85 |
| 86 const bool is_media_; | 86 const bool is_media_; |
| 87 URLRequestContextFactory* const factory_; | 87 URLRequestContextFactory* const factory_; |
| 88 scoped_ptr<net::URLRequestContext> request_context_; | 88 scoped_ptr<net::URLRequestContext> request_context_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 99 URLRequestContextFactory* factory, | 99 URLRequestContextFactory* factory, |
| 100 content::BrowserContext* browser_context, | 100 content::BrowserContext* browser_context, |
| 101 content::ProtocolHandlerMap* protocol_handlers, | 101 content::ProtocolHandlerMap* protocol_handlers, |
| 102 content::URLRequestInterceptorScopedVector request_interceptors) | 102 content::URLRequestInterceptorScopedVector request_interceptors) |
| 103 : browser_context_(browser_context), | 103 : browser_context_(browser_context), |
| 104 factory_(factory), | 104 factory_(factory), |
| 105 request_interceptors_(request_interceptors.Pass()) { | 105 request_interceptors_(request_interceptors.Pass()) { |
| 106 std::swap(protocol_handlers_, *protocol_handlers); | 106 std::swap(protocol_handlers_, *protocol_handlers); |
| 107 } | 107 } |
| 108 | 108 |
| 109 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE { | 109 virtual net::URLRequestContext* GetURLRequestContext() override { |
| 110 if (!request_context_) { | 110 if (!request_context_) { |
| 111 request_context_.reset(factory_->CreateMainRequestContext( | 111 request_context_.reset(factory_->CreateMainRequestContext( |
| 112 browser_context_, &protocol_handlers_, request_interceptors_.Pass())); | 112 browser_context_, &protocol_handlers_, request_interceptors_.Pass())); |
| 113 protocol_handlers_.clear(); | 113 protocol_handlers_.clear(); |
| 114 } | 114 } |
| 115 return request_context_.get(); | 115 return request_context_.get(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 virtual scoped_refptr<base::SingleThreadTaskRunner> | 118 virtual scoped_refptr<base::SingleThreadTaskRunner> |
| 119 GetNetworkTaskRunner() const OVERRIDE { | 119 GetNetworkTaskRunner() const override { |
| 120 return content::BrowserThread::GetMessageLoopProxyForThread( | 120 return content::BrowserThread::GetMessageLoopProxyForThread( |
| 121 content::BrowserThread::IO); | 121 content::BrowserThread::IO); |
| 122 } | 122 } |
| 123 | 123 |
| 124 private: | 124 private: |
| 125 virtual ~MainURLRequestContextGetter() {} | 125 virtual ~MainURLRequestContextGetter() {} |
| 126 | 126 |
| 127 content::BrowserContext* const browser_context_; | 127 content::BrowserContext* const browser_context_; |
| 128 URLRequestContextFactory* const factory_; | 128 URLRequestContextFactory* const factory_; |
| 129 content::ProtocolHandlerMap protocol_handlers_; | 129 content::ProtocolHandlerMap protocol_handlers_; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 406 |
| 407 void URLRequestContextFactory::InitializeNetworkDelegates() { | 407 void URLRequestContextFactory::InitializeNetworkDelegates() { |
| 408 app_network_delegate_->Initialize(false); | 408 app_network_delegate_->Initialize(false); |
| 409 LOG(INFO) << "Initialized app network delegate."; | 409 LOG(INFO) << "Initialized app network delegate."; |
| 410 system_network_delegate_->Initialize(false); | 410 system_network_delegate_->Initialize(false); |
| 411 LOG(INFO) << "Initialized system network delegate."; | 411 LOG(INFO) << "Initialized system network delegate."; |
| 412 } | 412 } |
| 413 | 413 |
| 414 } // namespace shell | 414 } // namespace shell |
| 415 } // namespace chromecast | 415 } // namespace chromecast |
| OLD | NEW |