diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-02 22:53:18 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-02 22:53:18 +0000 |
commit | e7f2964e84ca06d711d33723e7725d03ee2aa136 (patch) | |
tree | e2cc8f033863a972998fdd668dd698d222bea3aa /net/disk_cache/disk_cache.h | |
parent | e9e6b1c6d3870e9a1e9a8aa7e6c454cdcd354d0f (diff) | |
download | chromium_src-e7f2964e84ca06d711d33723e7725d03ee2aa136.zip chromium_src-e7f2964e84ca06d711d33723e7725d03ee2aa136.tar.gz chromium_src-e7f2964e84ca06d711d33723e7725d03ee2aa136.tar.bz2 |
Proposed change to support resource loading for media files.
Highlights of changes:
- Added methods to disk_cache::Entry:
- Entry::PrepareTargetAsExternalFile(int index)
Prepare a stream in an entry to use external file for storage.
- Entry::GetExternalFile(int index)
Get the external file backing the stream in the entry.
- Added a property "CacheType type_" to HttpCache, along with setter and getter.
There shall be two cache types, COMMON_CACHE and MEDIA_CACHE for distinguishing between different purpose of HttpCache. We have this property to trigger special behavior for caching needs of media files.
- Added static methods to ChromeURLRequestContext
- ChromeURLRequestContext::CreateOriginalForMedia
Create a URLRequestContext for media files for the original profile.
- ChromeURLRequestContext::CreateOffTheRecordForMedia
Create a URLRequestContext for media files for off the record profile.
- Added method to Profile interface.
- GetRequestContextForMedia
To get the request context for media files from the context.
Design decissions:
- Enforce writing to external file by calling methods to Entry rather than construct Backend by a different flag.
Since we only want a valid and full response to go into an external file rather than redirection response or erroneous response, we should let HttpCache::Transaction to decide when to have an external file for response data. We eliminate a lot of useless external cache files.
- Adding the CacheType enum and property to HttpCache, we could allow possible (?) future extensions to HttpCache to handle other different caching needs. And there's no need to add change constructors of HttpCache, but maybe we should add a specific constructor to accomodate a media HttpCache?
- Adding Profile::GetRequestContextForMedia()
Since we will need to use this new request context in ResourceDispatcherHost, I think the best place to keep it is in the profile. Also we will expose to user that there's a separate cache for media, so it's better to expose it in the Profile level to allow settings to the media cache, e.g. max file size, etc.
Review URL: http://codereview.chromium.org/19747
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10745 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/disk_cache.h')
-rw-r--r-- | net/disk_cache/disk_cache.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/net/disk_cache/disk_cache.h b/net/disk_cache/disk_cache.h index 59d2ad2..7d6e41a 100644 --- a/net/disk_cache/disk_cache.h +++ b/net/disk_cache/disk_cache.h @@ -12,6 +12,7 @@ #include <vector> #include "base/basictypes.h" +#include "base/platform_file.h" #include "base/time.h" #include "net/base/completion_callback.h" @@ -153,6 +154,29 @@ class Entry { net::CompletionCallback* completion_callback, bool truncate) = 0; + // Prepares a target stream as an external file, returns a corresponding + // base::PlatformFile if successful, returns base::kInvalidPlatformFileValue + // if fails. If this call returns a valid base::PlatformFile value (i.e. + // not base::kInvalidPlatformFileValue), there is no guarantee that the file + // is truncated. Implementor can always return base::kInvalidPlatformFileValue + // if external file is not available in that particular implementation. + // Caller should never close the file handle returned by this method, since + // the handle should be managed by the implementor of this class. Caller + // should never save the handle for future use. + // With a stream prepared as an external file, the stream would always be + // kept in an external file since creation, even if the stream has 0 bytes. + // So we need to be cautious about using this option for preparing a stream or + // we will end up having a lot of empty cache files. Calling this method also + // means that all data written to the stream will always be written to file + // directly *without* buffering. + virtual base::PlatformFile UseExternalFile(int index) = 0; + + // Returns a read file handle for the cache stream referenced by |index|. + // Caller should never close the handle returned by this method and should + // not save it for future use. The lifetime of the base::PlatformFile handle + // is managed by the implementor of this class. + virtual base::PlatformFile GetPlatformFile(int index) = 0; + protected: virtual ~Entry() {} }; |