summaryrefslogtreecommitdiffstats
path: root/webkit/blob/blob_url_request_job.h
diff options
context:
space:
mode:
authoradamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-14 20:02:05 +0000
committeradamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-14 20:02:05 +0000
commitb3b9b508b81bd690d4f8ec1cdc4b53d7e6db08a1 (patch)
tree8222cba1e35402823f1c1f2190052892cc7c1403 /webkit/blob/blob_url_request_job.h
parent18016982fceb89f48ed18b72afbdb26521e47c23 (diff)
downloadchromium_src-b3b9b508b81bd690d4f8ec1cdc4b53d7e6db08a1.zip
chromium_src-b3b9b508b81bd690d4f8ec1cdc4b53d7e6db08a1.tar.gz
chromium_src-b3b9b508b81bd690d4f8ec1cdc4b53d7e6db08a1.tar.bz2
In BlobURLRequestJob, open files asynchronously to avoid blocking the IO thread
(and tripping thread restriction asserts). The bug was found while trying to get FileWriter ui_tests to pass (see http://codereview.chromium.org/6609040/). This change also changes all callers to pass in a file_thread_proxy so the class can assume it's there and pass it to FileUtilProxy. Finally, it adds a BlobURLRequestJob test case that reads a file larger than the buffer size, to better exercise the job's behavior when ReadRawData() is called multiple times. BUG=75548 TEST=test_shell_tests,ui_tests Review URL: http://codereview.chromium.org/6612051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78079 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/blob/blob_url_request_job.h')
-rw-r--r--webkit/blob/blob_url_request_job.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/webkit/blob/blob_url_request_job.h b/webkit/blob/blob_url_request_job.h
index 2dec522..c5669bf 100644
--- a/webkit/blob/blob_url_request_job.h
+++ b/webkit/blob/blob_url_request_job.h
@@ -11,7 +11,6 @@
#include "base/scoped_ptr.h"
#include "base/task.h"
#include "net/base/completion_callback.h"
-#include "net/base/file_stream.h"
#include "net/http/http_byte_range.h"
#include "net/url_request/url_request_job.h"
#include "webkit/blob/blob_data.h"
@@ -21,6 +20,10 @@ class MessageLoopProxy;
struct PlatformFileInfo;
}
+namespace net {
+class FileStream;
+}
+
namespace webkit_blob {
// A request job that handles reading blob URLs.
@@ -41,15 +44,18 @@ class BlobURLRequestJob : public net::URLRequestJob {
virtual void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers);
private:
+ void CloseStream();
void ResolveFile(const FilePath& file_path);
void CountSize();
void Seek(int64 offset);
void AdvanceItem();
void AdvanceBytesRead(int result);
+ int ComputeBytesToRead() const;
bool ReadLoop(int* bytes_read);
bool ReadItem();
- bool ReadBytes(const BlobData::Item& item, int bytes_to_read);
- bool ReadFile(const BlobData::Item& item, int bytes_to_read);
+ bool ReadBytes(const BlobData::Item& item);
+ bool DispatchReadFile(const BlobData::Item& item);
+ bool ReadFile(const BlobData::Item& item);
void HeadersCompleted(int status_code, const std::string& status_txt);
int ReadCompleted();
void NotifySuccess();
@@ -58,6 +64,9 @@ class BlobURLRequestJob : public net::URLRequestJob {
void DidStart();
void DidResolve(base::PlatformFileError rv,
const base::PlatformFileInfo& file_info);
+ void DidOpen(base::PlatformFileError rv,
+ base::PassPlatformFile file,
+ bool created);
void DidRead(int result);
base::ScopedCallbackFactory<BlobURLRequestJob> callback_factory_;
@@ -65,7 +74,7 @@ class BlobURLRequestJob : public net::URLRequestJob {
scoped_refptr<base::MessageLoopProxy> file_thread_proxy_;
net::CompletionCallbackImpl<BlobURLRequestJob> io_callback_;
std::vector<int64> item_length_list_;
- net::FileStream stream_;
+ scoped_ptr<net::FileStream> stream_;
size_t item_index_;
int64 total_size_;
int64 current_item_offset_;
@@ -74,6 +83,7 @@ class BlobURLRequestJob : public net::URLRequestJob {
int read_buf_offset_;
int read_buf_size_;
int read_buf_remaining_bytes_;
+ int bytes_to_read_;
bool error_;
bool headers_set_;
bool byte_range_set_;