diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-26 21:16:01 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-26 21:16:01 +0000 |
commit | 18e7dc4c526b8727d1be436b6265baebbf583e76 (patch) | |
tree | 31a36412aa4dc0ca3e379612c072e86af9394e0e /net | |
parent | c5a7011822b46324a5c5223854e51af52323ff29 (diff) | |
download | chromium_src-18e7dc4c526b8727d1be436b6265baebbf583e76.zip chromium_src-18e7dc4c526b8727d1be436b6265baebbf583e76.tar.gz chromium_src-18e7dc4c526b8727d1be436b6265baebbf583e76.tar.bz2 |
URLRequestFileJob provides file handle if net::LOAD_ENABLE_DOWNLOAD_FILE
Make URLRequestFileJob to respect net::LOAD_ENABLE_DOWNLOAD_FILE
load flag. It reopens the file specified by file:/// URL and saves
the asynchronous file handle in HttpResponseInfo.
Review URL: http://codereview.chromium.org/42657
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12605 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/url_request/url_request_file_job.cc | 20 | ||||
-rw-r--r-- | net/url_request/url_request_file_job.h | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc index cc9de9b..097169f 100644 --- a/net/url_request/url_request_file_job.cc +++ b/net/url_request/url_request_file_job.cc @@ -21,9 +21,11 @@ #include "base/compiler_specific.h" #include "base/message_loop.h" +#include "base/platform_file.h" #include "base/string_util.h" #include "base/worker_pool.h" #include "googleurl/src/gurl.h" +#include "net/base/load_flags.h" #include "net/base/mime_util.h" #include "net/base/net_errors.h" #include "net/base/net_util.h" @@ -155,6 +157,24 @@ bool URLRequestFileJob::GetMimeType(std::string* mime_type) const { return net::GetMimeTypeFromFile(file_path_, mime_type); } +void URLRequestFileJob::GetResponseInfo(net::HttpResponseInfo* info) { + DCHECK(request_); + + // If we have enabled downloading the file, the requester expects to receive + // a file handle to the file. Since we are serving file:/// url requests we + // can provide such a handle if the file exists. + bool created; + if ((request_->load_flags() & net::LOAD_ENABLE_DOWNLOAD_FILE) && + stream_.IsOpen()) { + info->response_data_file = + base::CreatePlatformFile(file_path_.ToWStringHack(), + base::PLATFORM_FILE_OPEN | + base::PLATFORM_FILE_READ | + base::PLATFORM_FILE_ASYNC, + &created); + } +} + void URLRequestFileJob::DidResolve( bool exists, const file_util::FileInfo& file_info) { #if defined(OS_WIN) diff --git a/net/url_request/url_request_file_job.h b/net/url_request/url_request_file_job.h index 1558c61..94b65c4 100644 --- a/net/url_request/url_request_file_job.h +++ b/net/url_request/url_request_file_job.h @@ -25,6 +25,7 @@ class URLRequestFileJob : public URLRequestJob { virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); virtual bool IsRedirectResponse(GURL* location, int* http_status_code); virtual bool GetMimeType(std::string* mime_type) const; + virtual void GetResponseInfo(net::HttpResponseInfo* info); static URLRequest::ProtocolFactory Factory; |