Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1068)

Side by Side Diff: chromecast/browser/url_request_context_factory.cc

Issue 1875623002: Convert //chromecast from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h"
12 #include "base/threading/worker_pool.h" 13 #include "base/threading/worker_pool.h"
13 #include "chromecast/base/chromecast_switches.h" 14 #include "chromecast/base/chromecast_switches.h"
14 #include "chromecast/browser/cast_http_user_agent_settings.h" 15 #include "chromecast/browser/cast_http_user_agent_settings.h"
15 #include "chromecast/browser/cast_network_delegate.h" 16 #include "chromecast/browser/cast_network_delegate.h"
16 #include "content/public/browser/browser_context.h" 17 #include "content/public/browser/browser_context.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/cookie_store_factory.h" 19 #include "content/public/browser/cookie_store_factory.h"
19 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
20 #include "content/public/common/url_constants.h" 21 #include "content/public/common/url_constants.h"
21 #include "net/cert/cert_verifier.h" 22 #include "net/cert/cert_verifier.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 GetNetworkTaskRunner() const override { 79 GetNetworkTaskRunner() const override {
79 return content::BrowserThread::GetMessageLoopProxyForThread( 80 return content::BrowserThread::GetMessageLoopProxyForThread(
80 content::BrowserThread::IO); 81 content::BrowserThread::IO);
81 } 82 }
82 83
83 private: 84 private:
84 ~URLRequestContextGetter() override {} 85 ~URLRequestContextGetter() override {}
85 86
86 const bool is_media_; 87 const bool is_media_;
87 URLRequestContextFactory* const factory_; 88 URLRequestContextFactory* const factory_;
88 scoped_ptr<net::URLRequestContext> request_context_; 89 std::unique_ptr<net::URLRequestContext> request_context_;
89 90
90 DISALLOW_COPY_AND_ASSIGN(URLRequestContextGetter); 91 DISALLOW_COPY_AND_ASSIGN(URLRequestContextGetter);
91 }; 92 };
92 93
93 // The URLRequestContextFactory::MainURLRequestContextGetter class is used for 94 // The URLRequestContextFactory::MainURLRequestContextGetter class is used for
94 // the main URLRequestContext. 95 // the main URLRequestContext.
95 class URLRequestContextFactory::MainURLRequestContextGetter 96 class URLRequestContextFactory::MainURLRequestContextGetter
96 : public net::URLRequestContextGetter { 97 : public net::URLRequestContextGetter {
97 public: 98 public:
98 MainURLRequestContextGetter( 99 MainURLRequestContextGetter(
(...skipping 23 matching lines...) Expand all
122 content::BrowserThread::IO); 123 content::BrowserThread::IO);
123 } 124 }
124 125
125 private: 126 private:
126 ~MainURLRequestContextGetter() override {} 127 ~MainURLRequestContextGetter() override {}
127 128
128 content::BrowserContext* const browser_context_; 129 content::BrowserContext* const browser_context_;
129 URLRequestContextFactory* const factory_; 130 URLRequestContextFactory* const factory_;
130 content::ProtocolHandlerMap protocol_handlers_; 131 content::ProtocolHandlerMap protocol_handlers_;
131 content::URLRequestInterceptorScopedVector request_interceptors_; 132 content::URLRequestInterceptorScopedVector request_interceptors_;
132 scoped_ptr<net::URLRequestContext> request_context_; 133 std::unique_ptr<net::URLRequestContext> request_context_;
133 134
134 DISALLOW_COPY_AND_ASSIGN(MainURLRequestContextGetter); 135 DISALLOW_COPY_AND_ASSIGN(MainURLRequestContextGetter);
135 }; 136 };
136 137
137 URLRequestContextFactory::URLRequestContextFactory() 138 URLRequestContextFactory::URLRequestContextFactory()
138 : app_network_delegate_(CastNetworkDelegate::Create()), 139 : app_network_delegate_(CastNetworkDelegate::Create()),
139 system_network_delegate_(CastNetworkDelegate::Create()), 140 system_network_delegate_(CastNetworkDelegate::Create()),
140 system_dependencies_initialized_(false), 141 system_dependencies_initialized_(false),
141 main_dependencies_initialized_(false), 142 main_dependencies_initialized_(false),
142 media_dependencies_initialized_(false) { 143 media_dependencies_initialized_(false) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 220 }
220 221
221 void URLRequestContextFactory::InitializeMainContextDependencies( 222 void URLRequestContextFactory::InitializeMainContextDependencies(
222 net::HttpTransactionFactory* transaction_factory, 223 net::HttpTransactionFactory* transaction_factory,
223 content::ProtocolHandlerMap* protocol_handlers, 224 content::ProtocolHandlerMap* protocol_handlers,
224 content::URLRequestInterceptorScopedVector request_interceptors) { 225 content::URLRequestInterceptorScopedVector request_interceptors) {
225 if (main_dependencies_initialized_) 226 if (main_dependencies_initialized_)
226 return; 227 return;
227 228
228 main_transaction_factory_.reset(transaction_factory); 229 main_transaction_factory_.reset(transaction_factory);
229 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( 230 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory(
230 new net::URLRequestJobFactoryImpl()); 231 new net::URLRequestJobFactoryImpl());
231 // Keep ProtocolHandlers added in sync with 232 // Keep ProtocolHandlers added in sync with
232 // CastContentBrowserClient::IsHandledURL(). 233 // CastContentBrowserClient::IsHandledURL().
233 bool set_protocol = false; 234 bool set_protocol = false;
234 for (content::ProtocolHandlerMap::iterator it = protocol_handlers->begin(); 235 for (content::ProtocolHandlerMap::iterator it = protocol_handlers->begin();
235 it != protocol_handlers->end(); 236 it != protocol_handlers->end();
236 ++it) { 237 ++it) {
237 set_protocol = job_factory->SetProtocolHandler( 238 set_protocol = job_factory->SetProtocolHandler(
238 it->first, make_scoped_ptr(it->second.release())); 239 it->first, base::WrapUnique(it->second.release()));
239 DCHECK(set_protocol); 240 DCHECK(set_protocol);
240 } 241 }
241 set_protocol = job_factory->SetProtocolHandler( 242 set_protocol = job_factory->SetProtocolHandler(
242 url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler)); 243 url::kDataScheme, base::WrapUnique(new net::DataProtocolHandler));
243 DCHECK(set_protocol); 244 DCHECK(set_protocol);
244 245
245 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 246 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
246 switches::kEnableLocalFileAccesses)) { 247 switches::kEnableLocalFileAccesses)) {
247 set_protocol = job_factory->SetProtocolHandler( 248 set_protocol = job_factory->SetProtocolHandler(
248 url::kFileScheme, 249 url::kFileScheme,
249 make_scoped_ptr(new net::FileProtocolHandler( 250 base::WrapUnique(new net::FileProtocolHandler(
250 content::BrowserThread::GetBlockingPool() 251 content::BrowserThread::GetBlockingPool()
251 ->GetTaskRunnerWithShutdownBehavior( 252 ->GetTaskRunnerWithShutdownBehavior(
252 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)))); 253 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))));
253 DCHECK(set_protocol); 254 DCHECK(set_protocol);
254 } 255 }
255 256
256 // Set up interceptors in the reverse order. 257 // Set up interceptors in the reverse order.
257 scoped_ptr<net::URLRequestJobFactory> top_job_factory = 258 std::unique_ptr<net::URLRequestJobFactory> top_job_factory =
258 std::move(job_factory); 259 std::move(job_factory);
259 for (content::URLRequestInterceptorScopedVector::reverse_iterator i = 260 for (content::URLRequestInterceptorScopedVector::reverse_iterator i =
260 request_interceptors.rbegin(); 261 request_interceptors.rbegin();
261 i != request_interceptors.rend(); 262 i != request_interceptors.rend();
262 ++i) { 263 ++i) {
263 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( 264 top_job_factory.reset(new net::URLRequestInterceptingJobFactory(
264 std::move(top_job_factory), make_scoped_ptr(*i))); 265 std::move(top_job_factory), base::WrapUnique(*i)));
265 } 266 }
266 request_interceptors.weak_clear(); 267 request_interceptors.weak_clear();
267 268
268 main_job_factory_.reset(top_job_factory.release()); 269 main_job_factory_.reset(top_job_factory.release());
269 270
270 main_dependencies_initialized_ = true; 271 main_dependencies_initialized_ = true;
271 } 272 }
272 273
273 void URLRequestContextFactory::InitializeMediaContextDependencies( 274 void URLRequestContextFactory::InitializeMediaContextDependencies(
274 net::HttpTransactionFactory* transaction_factory) { 275 net::HttpTransactionFactory* transaction_factory) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 398
398 void URLRequestContextFactory::InitializeNetworkDelegates() { 399 void URLRequestContextFactory::InitializeNetworkDelegates() {
399 app_network_delegate_->Initialize(false); 400 app_network_delegate_->Initialize(false);
400 LOG(INFO) << "Initialized app network delegate."; 401 LOG(INFO) << "Initialized app network delegate.";
401 system_network_delegate_->Initialize(false); 402 system_network_delegate_->Initialize(false);
402 LOG(INFO) << "Initialized system network delegate."; 403 LOG(INFO) << "Initialized system network delegate.";
403 } 404 }
404 405
405 } // namespace shell 406 } // namespace shell
406 } // namespace chromecast 407 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/url_request_context_factory.h ('k') | chromecast/common/cast_resource_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698