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

Side by Side Diff: content/shell/browser/shell_url_request_context_getter.cc

Issue 1295523006: Using scoped_ptr for URLRequestJobFactoryImpl::SetProtocolHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/shell/browser/shell_url_request_context_getter.h" 5 #include "content/shell/browser/shell_url_request_context_getter.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 namespace { 46 namespace {
47 47
48 void InstallProtocolHandlers(net::URLRequestJobFactoryImpl* job_factory, 48 void InstallProtocolHandlers(net::URLRequestJobFactoryImpl* job_factory,
49 ProtocolHandlerMap* protocol_handlers) { 49 ProtocolHandlerMap* protocol_handlers) {
50 for (ProtocolHandlerMap::iterator it = 50 for (ProtocolHandlerMap::iterator it =
51 protocol_handlers->begin(); 51 protocol_handlers->begin();
52 it != protocol_handlers->end(); 52 it != protocol_handlers->end();
53 ++it) { 53 ++it) {
54 bool set_protocol = job_factory->SetProtocolHandler( 54 bool set_protocol = job_factory->SetProtocolHandler(
55 it->first, it->second.release()); 55 it->first, make_scoped_ptr(it->second.release()));
56 DCHECK(set_protocol); 56 DCHECK(set_protocol);
57 } 57 }
58 protocol_handlers->clear(); 58 protocol_handlers->clear();
59 } 59 }
60 60
61 } // namespace 61 } // namespace
62 62
63 ShellURLRequestContextGetter::ShellURLRequestContextGetter( 63 ShellURLRequestContextGetter::ShellURLRequestContextGetter(
64 bool ignore_certificate_errors, 64 bool ignore_certificate_errors,
65 const base::FilePath& base_path, 65 const base::FilePath& base_path,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 net::HttpCache* main_cache = new net::HttpCache( 202 net::HttpCache* main_cache = new net::HttpCache(
203 network_session_params, main_backend); 203 network_session_params, main_backend);
204 storage_->set_http_transaction_factory(main_cache); 204 storage_->set_http_transaction_factory(main_cache);
205 205
206 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( 206 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
207 new net::URLRequestJobFactoryImpl()); 207 new net::URLRequestJobFactoryImpl());
208 // Keep ProtocolHandlers added in sync with 208 // Keep ProtocolHandlers added in sync with
209 // ShellContentBrowserClient::IsHandledURL(). 209 // ShellContentBrowserClient::IsHandledURL().
210 InstallProtocolHandlers(job_factory.get(), &protocol_handlers_); 210 InstallProtocolHandlers(job_factory.get(), &protocol_handlers_);
211 bool set_protocol = job_factory->SetProtocolHandler( 211 bool set_protocol = job_factory->SetProtocolHandler(
212 url::kDataScheme, new net::DataProtocolHandler); 212 url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler));
213 DCHECK(set_protocol); 213 DCHECK(set_protocol);
214 #if !defined(DISABLE_FILE_SUPPORT) 214 #if !defined(DISABLE_FILE_SUPPORT)
215 set_protocol = job_factory->SetProtocolHandler( 215 set_protocol = job_factory->SetProtocolHandler(
216 url::kFileScheme, 216 url::kFileScheme,
217 new net::FileProtocolHandler( 217 make_scoped_ptr(new net::FileProtocolHandler(
218 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( 218 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
219 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); 219 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))));
220 DCHECK(set_protocol); 220 DCHECK(set_protocol);
221 #endif 221 #endif
222 222
223 // Set up interceptors in the reverse order. 223 // Set up interceptors in the reverse order.
224 scoped_ptr<net::URLRequestJobFactory> top_job_factory = 224 scoped_ptr<net::URLRequestJobFactory> top_job_factory =
225 job_factory.Pass(); 225 job_factory.Pass();
226 for (URLRequestInterceptorScopedVector::reverse_iterator i = 226 for (URLRequestInterceptorScopedVector::reverse_iterator i =
227 request_interceptors_.rbegin(); 227 request_interceptors_.rbegin();
228 i != request_interceptors_.rend(); 228 i != request_interceptors_.rend();
229 ++i) { 229 ++i) {
(...skipping 11 matching lines...) Expand all
241 scoped_refptr<base::SingleThreadTaskRunner> 241 scoped_refptr<base::SingleThreadTaskRunner>
242 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { 242 ShellURLRequestContextGetter::GetNetworkTaskRunner() const {
243 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 243 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
244 } 244 }
245 245
246 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { 246 net::HostResolver* ShellURLRequestContextGetter::host_resolver() {
247 return url_request_context_->host_resolver(); 247 return url_request_context_->host_resolver();
248 } 248 }
249 249
250 } // namespace content 250 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698