summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-13 20:06:57 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-13 20:06:57 +0000
commit363347b61871d82d0f84d14d5a24288ac79eddc3 (patch)
tree5cfc6dc4c874e9d23d3fc66ae4b9294bf549921b /net
parentcc7948aeb5fe21af08a2d5e868c0087ded0d244a (diff)
downloadchromium_src-363347b61871d82d0f84d14d5a24288ac79eddc3.zip
chromium_src-363347b61871d82d0f84d14d5a24288ac79eddc3.tar.gz
chromium_src-363347b61871d82d0f84d14d5a24288ac79eddc3.tar.bz2
Highlights of changes:
1. Added entry to ResourceResponseHead so that it contains either a base::PlatformFile (OS_WIN) or base::FileDescriptor (OS_POSIX) for passing the file handle from browser to renderer process. 2. Also added IPC messages for reporting download progress and ACK message for it. ResourceLoaderBridge::Peer::OnDownloadProgress is added so that the peer is notified of the download progress in the renderer process. 3. Load flag to kick start the resource loading for media files. LOAD_MEDIA_RESOURCE is added so that ResourceDispatcherHost knows how to use a different ResourceHandler for handling media resource request. Review URL: http://codereview.chromium.org/27168 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11661 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/load_flags.h3
-rw-r--r--net/disk_cache/disk_cache.h13
-rw-r--r--net/disk_cache/entry_impl.cc10
-rw-r--r--net/http/http_cache.cc20
-rw-r--r--net/http/http_cache_unittest.cc1
-rw-r--r--net/http/http_response_info.cc4
-rw-r--r--net/url_request/url_request.h7
7 files changed, 42 insertions, 16 deletions
diff --git a/net/base/load_flags.h b/net/base/load_flags.h
index 8557126..354980c 100644
--- a/net/base/load_flags.h
+++ b/net/base/load_flags.h
@@ -37,6 +37,9 @@ enum {
// If present, upload progress messages should be provided to initiator.
LOAD_ENABLE_UPLOAD_PROGRESS = 1 << 6,
+ // If present, try to download the resource to a standalone file.
+ LOAD_ENABLE_DOWNLOAD_FILE = 1 << 7,
+
// If present, ignores certificate mismatches with the domain name.
// (The default behavior is to trigger an OnSSLCertificateError callback.)
LOAD_IGNORE_CERT_COMMON_NAME_INVALID = 1 << 8,
diff --git a/net/disk_cache/disk_cache.h b/net/disk_cache/disk_cache.h
index 48b7ba5..3ea3b25 100644
--- a/net/disk_cache/disk_cache.h
+++ b/net/disk_cache/disk_cache.h
@@ -160,9 +160,8 @@ class Entry {
// 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.
+ // The caller should close the file handle returned by this method or there
+ // will be a leak.
// 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
@@ -171,10 +170,10 @@ class Entry {
// 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.
+ // Returns an asynchronous read file handle for the cache stream referenced by
+ // |index|. Values other than base::kInvalidPlatformFileValue are successful
+ // and the file handle should be managed by the caller, i.e. caller should
+ // close the handle after use or there will be a leak.
virtual base::PlatformFile GetPlatformFile(int index) = 0;
protected:
diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc
index 361a7ee..446138e 100644
--- a/net/disk_cache/entry_impl.cc
+++ b/net/disk_cache/entry_impl.cc
@@ -379,11 +379,11 @@ base::PlatformFile EntryImpl::GetPlatformFile(int index) {
if (!address.is_initialized() || !address.is_separate_file())
return base::kInvalidPlatformFileValue;
- File* cache_file = GetExternalFile(address, index);
- if (!cache_file)
- return base::kInvalidPlatformFileValue;
-
- return cache_file->platform_file();
+ return base::CreatePlatformFile(backend_->GetFileName(address),
+ base::PLATFORM_FILE_OPEN |
+ base::PLATFORM_FILE_READ |
+ base::PLATFORM_FILE_ASYNC,
+ NULL);
}
uint32 EntryImpl::GetHash() {
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index 75f0256..8637f2d 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -7,6 +7,11 @@
#include <algorithm>
#include "base/compiler_specific.h"
+
+#if defined(OS_POSIX)
+#include <unistd.h>
+#endif
+
#include "base/message_loop.h"
#include "base/pickle.h"
#include "base/ref_counted.h"
@@ -607,6 +612,15 @@ void HttpCache::Transaction::SetRequest(const HttpRequestInfo* request) {
if (cache_->mode() == RECORD)
effective_load_flags_ |= LOAD_BYPASS_CACHE;
+ // If HttpCache has type MEDIA make sure LOAD_ENABLE_DOWNLOAD_FILE is set,
+ // otherwise make sure LOAD_ENABLE_DOWNLOAD_FILE is not set when HttpCache
+ // has type other than MEDIA.
+ if (cache_->type() == HttpCache::MEDIA) {
+ DCHECK(effective_load_flags_ & LOAD_ENABLE_DOWNLOAD_FILE);
+ } else {
+ DCHECK(!(effective_load_flags_ & LOAD_ENABLE_DOWNLOAD_FILE));
+ }
+
// Some headers imply load flags. The order here is significant.
//
// LOAD_DISABLE_CACHE : no cache read or write
@@ -796,9 +810,10 @@ int HttpCache::Transaction::ReadResponseInfoFromEntry() {
// If the cache object is used for media file, we want the file handle of
// response data.
- if (cache_->type() == HttpCache::MEDIA)
+ if (cache_->type() == HttpCache::MEDIA) {
response_.response_data_file =
entry_->disk_entry->GetPlatformFile(kResponseContentIndex);
+ }
return OK;
}
@@ -869,9 +884,10 @@ void HttpCache::Transaction::TruncateResponseData() {
// if we get a valid response from server, i.e. 200. We don't want empty
// cache files for redirection or external files for erroneous requests.
response_.response_data_file = base::kInvalidPlatformFileValue;
- if (cache_->type() == HttpCache::MEDIA)
+ if (cache_->type() == HttpCache::MEDIA) {
response_.response_data_file =
entry_->disk_entry->UseExternalFile(kResponseContentIndex);
+ }
// Truncate the stream.
WriteToEntry(kResponseContentIndex, 0, NULL, 0);
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index 92980e1..61c2908 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -1227,6 +1227,7 @@ TEST(HttpCache, SimpleGET_MediaCache) {
#endif
ScopedMockTransaction trans_info(kSimpleGET_Transaction);
+ trans_info.load_flags |= net::LOAD_ENABLE_DOWNLOAD_FILE;
TestCompletionCallback callback;
{
diff --git a/net/http/http_response_info.cc b/net/http/http_response_info.cc
index ad6ef87..536d42b 100644
--- a/net/http/http_response_info.cc
+++ b/net/http/http_response_info.cc
@@ -3,12 +3,12 @@
// found in the LICENSE file.
#include "net/http/http_response_info.h"
-
#include "net/http/http_response_headers.h"
namespace net {
-HttpResponseInfo::HttpResponseInfo() {
+HttpResponseInfo::HttpResponseInfo()
+ : response_data_file(base::kInvalidPlatformFileValue) {
}
HttpResponseInfo::~HttpResponseInfo() {
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h
index 4309689..dcc999e 100644
--- a/net/url_request/url_request.h
+++ b/net/url_request/url_request.h
@@ -307,6 +307,13 @@ class URLRequest {
return response_info_.ssl_info;
}
+ // Returns the platform specific file handle for the standalone file that
+ // contains response data. base::kInvalidPlatformFileValue is returned if
+ // such file is not available.
+ base::PlatformFile response_data_file() {
+ return response_info_.response_data_file;
+ }
+
// Returns the cookie values included in the response, if the request is one
// that can have cookies. Returns true if the request is a cookie-bearing
// type, false otherwise. This method may only be called once the