OLD | NEW |
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 "chrome/browser/profiles/profile_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 #endif | 218 #endif |
219 | 219 |
220 initialized_on_UI_thread_ = true; | 220 initialized_on_UI_thread_ = true; |
221 | 221 |
222 // We need to make sure that content initializes its own data structures that | 222 // We need to make sure that content initializes its own data structures that |
223 // are associated with each ResourceContext because we might post this | 223 // are associated with each ResourceContext because we might post this |
224 // object to the IO thread after this function. | 224 // object to the IO thread after this function. |
225 BrowserContext::EnsureResourceContextInitialized(profile); | 225 BrowserContext::EnsureResourceContextInitialized(profile); |
226 } | 226 } |
227 | 227 |
| 228 ProfileIOData::MediaRequestContext::MediaRequestContext( |
| 229 chrome_browser_net::CacheStats* cache_stats) |
| 230 : ChromeURLRequestContext(ChromeURLRequestContext::CONTEXT_TYPE_MEDIA, |
| 231 cache_stats) { |
| 232 } |
| 233 |
| 234 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory( |
| 235 net::HttpTransactionFactory* http_factory) { |
| 236 http_factory_.reset(http_factory); |
| 237 set_http_transaction_factory(http_factory); |
| 238 } |
| 239 |
| 240 ProfileIOData::MediaRequestContext::~MediaRequestContext() {} |
| 241 |
228 ProfileIOData::AppRequestContext::AppRequestContext( | 242 ProfileIOData::AppRequestContext::AppRequestContext( |
229 chrome_browser_net::CacheStats* cache_stats) | 243 chrome_browser_net::CacheStats* cache_stats) |
230 : ChromeURLRequestContext(ChromeURLRequestContext::CONTEXT_TYPE_APP, | 244 : ChromeURLRequestContext(ChromeURLRequestContext::CONTEXT_TYPE_APP, |
231 cache_stats) { | 245 cache_stats) { |
232 } | 246 } |
233 | 247 |
234 void ProfileIOData::AppRequestContext::SetCookieStore( | 248 void ProfileIOData::AppRequestContext::SetCookieStore( |
235 net::CookieStore* cookie_store) { | 249 net::CookieStore* cookie_store) { |
236 cookie_store_ = cookie_store; | 250 cookie_store_ = cookie_store; |
237 set_cookie_store(cookie_store); | 251 set_cookie_store(cookie_store); |
(...skipping 27 matching lines...) Expand all Loading... |
265 } | 279 } |
266 | 280 |
267 ProfileIOData::~ProfileIOData() { | 281 ProfileIOData::~ProfileIOData() { |
268 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) | 282 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) |
269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 283 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
270 | 284 |
271 if (main_request_context_.get()) | 285 if (main_request_context_.get()) |
272 main_request_context_->AssertNoURLRequests(); | 286 main_request_context_->AssertNoURLRequests(); |
273 if (extensions_request_context_.get()) | 287 if (extensions_request_context_.get()) |
274 extensions_request_context_->AssertNoURLRequests(); | 288 extensions_request_context_->AssertNoURLRequests(); |
275 for (AppRequestContextMap::iterator it = app_request_context_map_.begin(); | 289 for (URLRequestContextMap::iterator it = app_request_context_map_.begin(); |
276 it != app_request_context_map_.end(); ++it) { | 290 it != app_request_context_map_.end(); ++it) { |
277 it->second->AssertNoURLRequests(); | 291 it->second->AssertNoURLRequests(); |
278 delete it->second; | 292 delete it->second; |
279 } | 293 } |
| 294 for (URLRequestContextMap::iterator it = |
| 295 isolated_media_request_context_map_.begin(); |
| 296 it != isolated_media_request_context_map_.end(); ++it) { |
| 297 it->second->AssertNoURLRequests(); |
| 298 delete it->second; |
| 299 } |
280 } | 300 } |
281 | 301 |
282 // static | 302 // static |
283 ProfileIOData* ProfileIOData::FromResourceContext( | 303 ProfileIOData* ProfileIOData::FromResourceContext( |
284 content::ResourceContext* rc) { | 304 content::ResourceContext* rc) { |
285 return (static_cast<ResourceContext*>(rc))->io_data_; | 305 return (static_cast<ResourceContext*>(rc))->io_data_; |
286 } | 306 } |
287 | 307 |
288 // static | 308 // static |
289 bool ProfileIOData::IsHandledProtocol(const std::string& scheme) { | 309 bool ProfileIOData::IsHandledProtocol(const std::string& scheme) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 if (ContainsKey(app_request_context_map_, app_id)) { | 376 if (ContainsKey(app_request_context_map_, app_id)) { |
357 context = app_request_context_map_[app_id]; | 377 context = app_request_context_map_[app_id]; |
358 } else { | 378 } else { |
359 context = AcquireIsolatedAppRequestContext(main_context, app_id); | 379 context = AcquireIsolatedAppRequestContext(main_context, app_id); |
360 app_request_context_map_[app_id] = context; | 380 app_request_context_map_[app_id] = context; |
361 } | 381 } |
362 DCHECK(context); | 382 DCHECK(context); |
363 return context; | 383 return context; |
364 } | 384 } |
365 | 385 |
| 386 ChromeURLRequestContext* |
| 387 ProfileIOData::GetIsolatedMediaRequestContext( |
| 388 ChromeURLRequestContext* main_context, |
| 389 const std::string& app_id) const { |
| 390 LazyInitialize(); |
| 391 ChromeURLRequestContext* context; |
| 392 if (ContainsKey(isolated_media_request_context_map_, app_id)) { |
| 393 context = isolated_media_request_context_map_[app_id]; |
| 394 } else { |
| 395 // Get the app context as the starting point for the media context, |
| 396 // so that it uses the app's cookie store. |
| 397 ChromeURLRequestContext* app_context = GetIsolatedAppRequestContext( |
| 398 main_context, app_id); |
| 399 context = AcquireIsolatedMediaRequestContext(app_context, app_id); |
| 400 isolated_media_request_context_map_[app_id] = context; |
| 401 } |
| 402 DCHECK(context); |
| 403 return context; |
| 404 } |
| 405 |
366 ExtensionInfoMap* ProfileIOData::GetExtensionInfoMap() const { | 406 ExtensionInfoMap* ProfileIOData::GetExtensionInfoMap() const { |
367 DCHECK(extension_info_map_) << "ExtensionSystem not initialized"; | 407 DCHECK(extension_info_map_) << "ExtensionSystem not initialized"; |
368 return extension_info_map_; | 408 return extension_info_map_; |
369 } | 409 } |
370 | 410 |
371 CookieSettings* ProfileIOData::GetCookieSettings() const { | 411 CookieSettings* ProfileIOData::GetCookieSettings() const { |
372 return cookie_settings_; | 412 return cookie_settings_; |
373 } | 413 } |
374 | 414 |
375 #if defined(ENABLE_NOTIFICATIONS) | 415 #if defined(ENABLE_NOTIFICATIONS) |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 649 } |
610 | 650 |
611 void ProfileIOData::set_server_bound_cert_service( | 651 void ProfileIOData::set_server_bound_cert_service( |
612 net::ServerBoundCertService* server_bound_cert_service) const { | 652 net::ServerBoundCertService* server_bound_cert_service) const { |
613 server_bound_cert_service_.reset(server_bound_cert_service); | 653 server_bound_cert_service_.reset(server_bound_cert_service); |
614 } | 654 } |
615 | 655 |
616 void ProfileIOData::DestroyResourceContext() { | 656 void ProfileIOData::DestroyResourceContext() { |
617 resource_context_.reset(); | 657 resource_context_.reset(); |
618 } | 658 } |
OLD | NEW |