diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 67 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.h | 6 |
2 files changed, 43 insertions, 30 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 528c0e1..40050b0 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -108,6 +108,41 @@ ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginal( ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForMedia( Profile* profile, const FilePath& disk_cache_path) { DCHECK(!profile->IsOffTheRecord()); + return CreateRequestContextForMedia(profile, disk_cache_path); +} + +// static +ChromeURLRequestContext* ChromeURLRequestContext::CreateOffTheRecord( + Profile* profile) { + DCHECK(profile->IsOffTheRecord()); + ChromeURLRequestContext* context = new ChromeURLRequestContext(profile); + + // Share the same proxy service as the original profile. This proxy + // service's lifespan is dependent on the lifespan of the original profile, + // which we reference (see above). + context->proxy_service_ = + profile->GetOriginalProfile()->GetRequestContext()->proxy_service(); + + context->http_transaction_factory_ = + new net::HttpCache(context->proxy_service_, 0); + context->cookie_store_ = new net::CookieMonster; + + return context; +} + +// static +ChromeURLRequestContext* ChromeURLRequestContext::CreateOffTheRecordForMedia( + Profile* profile, const FilePath& disk_cache_path) { + // TODO(hclam): since we don't have an implementation of disk cache backend + // for media files in OTR mode, we create a request context just like the + // original one. + DCHECK(profile->IsOffTheRecord()); + return CreateRequestContextForMedia(profile, disk_cache_path); +} + +// static +ChromeURLRequestContext* ChromeURLRequestContext::CreateRequestContextForMedia( + Profile* profile, const FilePath& disk_cache_path) { URLRequestContext* original_context = profile->GetOriginalProfile()->GetRequestContext(); ChromeURLRequestContext* context = new ChromeURLRequestContext(profile); @@ -130,12 +165,12 @@ ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForMedia( net::HttpNetworkLayer* original_network_layer = static_cast<net::HttpNetworkLayer*>(original_cache->network_layer()); cache = new net::HttpCache(original_network_layer->GetSession(), - disk_cache_path.ToWStringHack(), kint32max); + disk_cache_path.ToWStringHack(), kint32max); } else { // If original HttpCache doesn't exist, simply construct one with a whole // new set of network stack. cache = new net::HttpCache(original_context->proxy_service(), - disk_cache_path.ToWStringHack(), kint32max); + disk_cache_path.ToWStringHack(), kint32max); } // Set the cache type to media. cache->set_type(net::HttpCache::MEDIA); @@ -144,34 +179,6 @@ ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForMedia( return context; } -// static -ChromeURLRequestContext* ChromeURLRequestContext::CreateOffTheRecord( - Profile* profile) { - DCHECK(profile->IsOffTheRecord()); - ChromeURLRequestContext* context = new ChromeURLRequestContext(profile); - - // Share the same proxy service as the original profile. This proxy - // service's lifespan is dependent on the lifespan of the original profile, - // which we reference (see above). - context->proxy_service_ = - profile->GetOriginalProfile()->GetRequestContext()->proxy_service(); - - context->http_transaction_factory_ = - new net::HttpCache(context->proxy_service_, 0); - context->cookie_store_ = new net::CookieMonster; - - return context; -} - -// static -ChromeURLRequestContext* ChromeURLRequestContext::CreateOffTheRecordForMedia( - Profile* profile, const FilePath& disk_cache_path) { - // TODO(hclam): since we don't have an implementation of disk cache backend - // for media files in OTR mode, we use the original context first. Change this - // to the proper backend later. - return CreateOriginalForMedia(profile, disk_cache_path); -} - ChromeURLRequestContext::ChromeURLRequestContext(Profile* profile) : prefs_(profile->GetPrefs()), is_off_the_record_(profile->IsOffTheRecord()) { diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index df8cc9b..2215199 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -61,6 +61,12 @@ class ChromeURLRequestContext : public URLRequestContext, // expected to be called on the UI thread. ChromeURLRequestContext(Profile* profile); + // Create a request context for media resources from a regular request + // context. This helper method is called from CreateOriginalForMedia and + // CreateOffTheRecordForMedia. + static ChromeURLRequestContext* CreateRequestContextForMedia(Profile* profile, + const FilePath& disk_cache_path); + // NotificationObserver implementation. virtual void Observe(NotificationType type, const NotificationSource& source, |