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