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

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

Issue 10299002: Stop refcounting URLRequestContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More fixes Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/shell_url_request_context_getter.h" 5 #include "content/shell/shell_url_request_context_getter.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_split.h" 8 #include "base/string_split.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/shell/shell_network_delegate.h" 10 #include "content/shell/shell_network_delegate.h"
(...skipping 30 matching lines...) Expand all
41 net::ProxyService::CreateSystemProxyConfigService( 41 net::ProxyService::CreateSystemProxyConfigService(
42 io_loop_, file_loop_)); 42 io_loop_, file_loop_));
43 } 43 }
44 44
45 ShellURLRequestContextGetter::~ShellURLRequestContextGetter() { 45 ShellURLRequestContextGetter::~ShellURLRequestContextGetter() {
46 } 46 }
47 47
48 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { 48 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
50 50
51 if (!url_request_context_) { 51 if (!url_request_context_.get()) {
52 url_request_context_ = new net::URLRequestContext(); 52 url_request_context_.reset(new net::URLRequestContext());
53 network_delegate_.reset(new ShellNetworkDelegate); 53 network_delegate_.reset(new ShellNetworkDelegate);
54 url_request_context_->set_network_delegate(network_delegate_.get()); 54 url_request_context_->set_network_delegate(network_delegate_.get());
55 storage_.reset(new net::URLRequestContextStorage(url_request_context_)); 55 storage_.reset(
56 new net::URLRequestContextStorage(url_request_context_.get()));
56 storage_->set_cookie_store(new net::CookieMonster(NULL, NULL)); 57 storage_->set_cookie_store(new net::CookieMonster(NULL, NULL));
57 storage_->set_server_bound_cert_service(new net::ServerBoundCertService( 58 storage_->set_server_bound_cert_service(new net::ServerBoundCertService(
58 new net::DefaultServerBoundCertStore(NULL))); 59 new net::DefaultServerBoundCertStore(NULL)));
59 url_request_context_->set_accept_language("en-us,en"); 60 url_request_context_->set_accept_language("en-us,en");
60 url_request_context_->set_accept_charset("iso-8859-1,*,utf-8"); 61 url_request_context_->set_accept_charset("iso-8859-1,*,utf-8");
61 62
62 storage_->set_host_resolver( 63 storage_->set_host_resolver(
63 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, 64 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
64 net::HostResolver::kDefaultRetryAttempts, 65 net::HostResolver::kDefaultRetryAttempts,
65 NULL)); 66 NULL));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 url_request_context_->network_delegate(), 98 url_request_context_->network_delegate(),
98 url_request_context_->http_server_properties(), 99 url_request_context_->http_server_properties(),
99 NULL, 100 NULL,
100 main_backend, 101 main_backend,
101 "" /* trusted_spdy_proxy */ ); 102 "" /* trusted_spdy_proxy */ );
102 storage_->set_http_transaction_factory(main_cache); 103 storage_->set_http_transaction_factory(main_cache);
103 104
104 storage_->set_job_factory(new net::URLRequestJobFactory); 105 storage_->set_job_factory(new net::URLRequestJobFactory);
105 } 106 }
106 107
107 return url_request_context_; 108 return url_request_context_.get();
108 } 109 }
109 110
110 scoped_refptr<base::MessageLoopProxy> 111 scoped_refptr<base::MessageLoopProxy>
111 ShellURLRequestContextGetter::GetIOMessageLoopProxy() const { 112 ShellURLRequestContextGetter::GetIOMessageLoopProxy() const {
112 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 113 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
113 } 114 }
114 115
115 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { 116 net::HostResolver* ShellURLRequestContextGetter::host_resolver() {
116 return url_request_context_->host_resolver(); 117 return url_request_context_->host_resolver();
117 } 118 }
118 119
119 } // namespace content 120 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698