| Index: chrome/browser/renderer_host/redirect_to_file_resource_handler.cc
|
| ===================================================================
|
| --- chrome/browser/renderer_host/redirect_to_file_resource_handler.cc (revision 60424)
|
| +++ chrome/browser/renderer_host/redirect_to_file_resource_handler.cc (working copy)
|
| @@ -16,10 +16,7 @@
|
| #include "net/base/io_buffer.h"
|
| #include "net/base/mime_sniffer.h"
|
| #include "net/base/net_errors.h"
|
| -#include "webkit/blob/deletable_file_reference.h"
|
|
|
| -using webkit_blob::DeletableFileReference;
|
| -
|
| // TODO(darin): Use the buffer sizing algorithm from AsyncResourceHandler.
|
| static const int kReadBufSize = 32768;
|
|
|
| @@ -59,8 +56,8 @@
|
| int request_id,
|
| ResourceResponse* response) {
|
| if (response->response_head.status.is_success()) {
|
| - DCHECK(deletable_file_ && !deletable_file_->path().empty());
|
| - response->response_head.download_file_path = deletable_file_->path();
|
| + DCHECK(!file_path_.empty());
|
| + response->response_head.download_file_path = file_path_;
|
| }
|
| return next_handler_->OnResponseStarted(request_id, response);
|
| }
|
| @@ -69,7 +66,7 @@
|
| const GURL& url,
|
| bool* defer) {
|
| request_id_ = request_id;
|
| - if (!deletable_file_) {
|
| + if (file_path_.empty()) {
|
| // Defer starting the request until we have created the temporary file.
|
| // TODO(darin): This is sub-optimal. We should not delay starting the
|
| // network request like this.
|
| @@ -126,9 +123,6 @@
|
| if (BufIsFull())
|
| host_->PauseRequest(process_id_, request_id, true);
|
|
|
| - if (*bytes_read > 0)
|
| - next_handler_->OnDataDownloaded(request_id, *bytes_read);
|
| -
|
| return WriteMore();
|
| }
|
|
|
| @@ -140,13 +134,21 @@
|
| }
|
|
|
| void RedirectToFileResourceHandler::OnRequestClosed() {
|
| + next_handler_->OnRequestClosed();
|
| +
|
| + // The renderer no longer has a WebURLLoader open to this request, so we can
|
| + // close and unlink the file.
|
| +
|
| // We require this explicit call to Close since file_stream_ was constructed
|
| // directly from a PlatformFile.
|
| file_stream_->Close();
|
| file_stream_.reset();
|
| - deletable_file_ = NULL;
|
|
|
| - next_handler_->OnRequestClosed();
|
| + // TODO(dumi): delete the temp file when it's no longer needed.
|
| + // TODO(dumi): revoke the privilege to upload this file.
|
| + // base::FileUtilProxy::Delete(
|
| + // ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE),
|
| + // file_path_, NULL);
|
| }
|
|
|
| RedirectToFileResourceHandler::~RedirectToFileResourceHandler() {
|
| @@ -157,14 +159,12 @@
|
| base::PlatformFileError /*error_code*/,
|
| base::PassPlatformFile file_handle,
|
| FilePath file_path) {
|
| - deletable_file_ = DeletableFileReference::GetOrCreate(
|
| - file_path,
|
| - ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE));
|
| + file_path_ = file_path;
|
| file_stream_.reset(new net::FileStream(file_handle.ReleaseValue(),
|
| base::PLATFORM_FILE_WRITE |
|
| base::PLATFORM_FILE_ASYNC));
|
| - host_->RegisterDownloadedTempFile(
|
| - process_id_, request_id_, deletable_file_.get());
|
| + ChildProcessSecurityPolicy::GetInstance()->GrantUploadFile(
|
| + process_id_, file_path);
|
| host_->StartDeferredRequest(process_id_, request_id_);
|
| }
|
|
|
|
|