summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-23 18:45:45 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-23 18:45:45 +0000
commit3dac4560bd1ceb6abe94aaabc0bbee7ac7a87236 (patch)
tree456a018e0150cb85f942fdc6c4afda5b68f6c162 /chrome/browser/net
parent21b316afcfbe457fcab1ab1fd749595e1fe31696 (diff)
downloadchromium_src-3dac4560bd1ceb6abe94aaabc0bbee7ac7a87236.zip
chromium_src-3dac4560bd1ceb6abe94aaabc0bbee7ac7a87236.tar.gz
chromium_src-3dac4560bd1ceb6abe94aaabc0bbee7ac7a87236.tar.bz2
Fix an invalid DCHECK for media request context
BUG=9082 Since I forwarded CreateOffTheRecordForMedia to CreateOriginalForMedia, it triggers a DCHECK. Since the implementation of off the record media cache is not going to be implemented soon, I duplicated the implementation of CreateOriginalForMedia. Review URL: http://codereview.chromium.org/42467 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12297 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc67
-rw-r--r--chrome/browser/net/chrome_url_request_context.h6
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,