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 "chrome/browser/net/chrome_url_request_context_getter.h" | 5 #include "chrome/browser/net/chrome_url_request_context_getter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 : factory_(factory), | 172 : factory_(factory), |
173 url_request_context_(NULL) { | 173 url_request_context_(NULL) { |
174 DCHECK(factory); | 174 DCHECK(factory); |
175 } | 175 } |
176 | 176 |
177 ChromeURLRequestContextGetter::~ChromeURLRequestContextGetter() {} | 177 ChromeURLRequestContextGetter::~ChromeURLRequestContextGetter() {} |
178 | 178 |
179 // Lazily create a URLRequestContext using our factory. | 179 // Lazily create a URLRequestContext using our factory. |
180 net::URLRequestContext* | 180 net::URLRequestContext* |
181 ChromeURLRequestContextGetter::GetURLRequestContext() { | 181 ChromeURLRequestContextGetter::GetURLRequestContext() { |
182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 182 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
183 | 183 |
184 if (factory_.get()) { | 184 if (factory_.get()) { |
185 DCHECK(!url_request_context_); | 185 DCHECK(!url_request_context_); |
186 url_request_context_ = factory_->Create(); | 186 url_request_context_ = factory_->Create(); |
187 factory_.reset(); | 187 factory_.reset(); |
188 } | 188 } |
189 | 189 |
190 // Context reference is valid, unless we're trying to use the | 190 // Context reference is valid, unless we're trying to use the |
191 // URLRequestContextGetter after the Profile has already been deleted. | 191 // URLRequestContextGetter after the Profile has already been deleted. |
192 CHECK(url_request_context_); | 192 CHECK(url_request_context_); |
193 | 193 |
194 return url_request_context_; | 194 return url_request_context_; |
195 } | 195 } |
196 | 196 |
197 void ChromeURLRequestContextGetter::Invalidate() { | 197 void ChromeURLRequestContextGetter::Invalidate() { |
198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 198 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
199 factory_.reset(); | 199 factory_.reset(); |
200 url_request_context_ = NULL; | 200 url_request_context_ = NULL; |
201 } | 201 } |
202 | 202 |
203 scoped_refptr<base::SingleThreadTaskRunner> | 203 scoped_refptr<base::SingleThreadTaskRunner> |
204 ChromeURLRequestContextGetter::GetNetworkTaskRunner() const { | 204 ChromeURLRequestContextGetter::GetNetworkTaskRunner() const { |
205 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 205 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
206 } | 206 } |
207 | 207 |
208 // static | 208 // static |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 ChromeURLRequestContextGetter* | 256 ChromeURLRequestContextGetter* |
257 ChromeURLRequestContextGetter::CreateForIsolatedMedia( | 257 ChromeURLRequestContextGetter::CreateForIsolatedMedia( |
258 Profile* profile, | 258 Profile* profile, |
259 ChromeURLRequestContextGetter* app_context, | 259 ChromeURLRequestContextGetter* app_context, |
260 const ProfileIOData* profile_io_data, | 260 const ProfileIOData* profile_io_data, |
261 const StoragePartitionDescriptor& partition_descriptor) { | 261 const StoragePartitionDescriptor& partition_descriptor) { |
262 return new ChromeURLRequestContextGetter( | 262 return new ChromeURLRequestContextGetter( |
263 new FactoryForIsolatedMedia( | 263 new FactoryForIsolatedMedia( |
264 profile_io_data, partition_descriptor, app_context)); | 264 profile_io_data, partition_descriptor, app_context)); |
265 } | 265 } |
OLD | NEW |