diff options
author | adamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 21:54:26 +0000 |
---|---|---|
committer | adamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 21:54:26 +0000 |
commit | 4f61e0e76ac6a0fb034cfd0973d06e5216ada7fc (patch) | |
tree | a147b9873e5624ddf99e9f71ec595abad9ce4812 /webkit/fileapi | |
parent | 8d5ddd0a8fa11345e3894e5d58f6fdf395d76fef (diff) | |
download | chromium_src-4f61e0e76ac6a0fb034cfd0973d06e5216ada7fc.zip chromium_src-4f61e0e76ac6a0fb034cfd0973d06e5216ada7fc.tar.gz chromium_src-4f61e0e76ac6a0fb034cfd0973d06e5216ada7fc.tar.bz2 |
Several bits of cleanup in FileSystem*URLRequestJob:
- Remove startup_error_ member and delayed error reporting;
URLRequestJob properly enqueues NotifyDone calls so that
they complete after Start() runs.
- Remove origin_url_ members, replace with locals.
- Re-organize .h file to call out FilterContext method.
Review URL: http://codereview.chromium.org/6458011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74339 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r-- | webkit/fileapi/file_system_dir_url_request_job.cc | 5 | ||||
-rw-r--r-- | webkit/fileapi/file_system_dir_url_request_job.h | 9 | ||||
-rw-r--r-- | webkit/fileapi/file_system_url_request_job.cc | 13 | ||||
-rw-r--r-- | webkit/fileapi/file_system_url_request_job.h | 13 | ||||
-rw-r--r-- | webkit/fileapi/file_system_url_request_job_unittest.cc | 1 |
5 files changed, 20 insertions, 21 deletions
diff --git a/webkit/fileapi/file_system_dir_url_request_job.cc b/webkit/fileapi/file_system_dir_url_request_job.cc index 95ba462..73b1fa4 100644 --- a/webkit/fileapi/file_system_dir_url_request_job.cc +++ b/webkit/fileapi/file_system_dir_url_request_job.cc @@ -75,15 +75,16 @@ bool FileSystemDirURLRequestJob::GetCharset(std::string* charset) { } void FileSystemDirURLRequestJob::StartAsync() { + GURL origin_url; FileSystemType type; - if (!CrackFileSystemURL(request_->url(), &origin_url_, &type, + if (!CrackFileSystemURL(request_->url(), &origin_url, &type, &relative_dir_path_)) { NotifyFailed(net::ERR_INVALID_URL); return; } path_manager_->GetFileSystemRootPath( - origin_url_, type, false, // create + origin_url, type, false, // create callback_factory_.NewCallback( &FileSystemDirURLRequestJob::DidGetRootPath)); } diff --git a/webkit/fileapi/file_system_dir_url_request_job.h b/webkit/fileapi/file_system_dir_url_request_job.h index e7b2184..1d438c4 100644 --- a/webkit/fileapi/file_system_dir_url_request_job.h +++ b/webkit/fileapi/file_system_dir_url_request_job.h @@ -15,7 +15,6 @@ #include "base/platform_file.h" #include "base/scoped_callback_factory.h" #include "base/task.h" -#include "googleurl/src/gurl.h" #include "net/url_request/url_request_job.h" namespace fileapi { @@ -32,9 +31,12 @@ class FileSystemDirURLRequestJob : public net::URLRequestJob { virtual void Start(); virtual void Kill(); virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); - virtual bool GetMimeType(std::string* mime_type) const; virtual bool GetCharset(std::string* charset); - // TODO(adamk): Implement the rest of the methods required to simulate HTTP. + + // FilterContext methods (via URLRequestJob): + virtual bool GetMimeType(std::string* mime_type) const; + // TODO(adamk): Implement GetResponseInfo and GetResponseCode to simulate + // an HTTP response. private: virtual ~FileSystemDirURLRequestJob(); @@ -50,7 +52,6 @@ class FileSystemDirURLRequestJob : public net::URLRequestJob { std::string data_; FilePath relative_dir_path_; FilePath absolute_dir_path_; - GURL origin_url_; FileSystemPathManager* const path_manager_; ScopedRunnableMethodFactory<FileSystemDirURLRequestJob> method_factory_; diff --git a/webkit/fileapi/file_system_url_request_job.cc b/webkit/fileapi/file_system_url_request_job.cc index c8b1c76..3eb0842 100644 --- a/webkit/fileapi/file_system_url_request_job.cc +++ b/webkit/fileapi/file_system_url_request_job.cc @@ -41,7 +41,6 @@ FileSystemURLRequestJob::FileSystemURLRequestJob( stream_(NULL), is_directory_(false), remaining_bytes_(0), - startup_error_(0), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)), file_thread_proxy_(file_thread_proxy) { @@ -125,27 +124,23 @@ void FileSystemURLRequestJob::SetExtraRequestHeaders( // We don't support multiple range requests in one single URL request. // TODO(adamk): decide whether we want to support multiple range // requests. - startup_error_ = net::ERR_REQUEST_RANGE_NOT_SATISFIABLE; + NotifyFailed(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE); } } } } void FileSystemURLRequestJob::StartAsync() { - if (startup_error_) { - NotifyFailed(startup_error_); - return; - } - + GURL origin_url; FileSystemType type; - if (!CrackFileSystemURL(request_->url(), &origin_url_, &type, + if (!CrackFileSystemURL(request_->url(), &origin_url, &type, &relative_file_path_)) { NotifyFailed(net::ERR_INVALID_URL); return; } path_manager_->GetFileSystemRootPath( - origin_url_, type, false, // create + origin_url, type, false, // create callback_factory_.NewCallback(&FileSystemURLRequestJob::DidGetRootPath)); } diff --git a/webkit/fileapi/file_system_url_request_job.h b/webkit/fileapi/file_system_url_request_job.h index c49d873..bc25f75 100644 --- a/webkit/fileapi/file_system_url_request_job.h +++ b/webkit/fileapi/file_system_url_request_job.h @@ -14,11 +14,12 @@ #include "base/scoped_callback_factory.h" #include "base/scoped_ptr.h" #include "base/task.h" -#include "googleurl/src/gurl.h" #include "net/base/completion_callback.h" #include "net/http/http_byte_range.h" #include "net/url_request/url_request_job.h" +class GURL; + namespace net { class FileStream; } @@ -38,9 +39,13 @@ class FileSystemURLRequestJob : public net::URLRequestJob { virtual void Kill(); 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 SetExtraRequestHeaders(const net::HttpRequestHeaders& headers); - // TODO(adamk): Implement the rest of the methods required to simulate HTTP. + + // FilterContext methods (via URLRequestJob): + virtual bool GetMimeType(std::string* mime_type) const; + + // TODO(adamk): Implement GetResponseInfo and GetResponseCode to simulate + // an HTTP response. private: virtual ~FileSystemURLRequestJob(); @@ -58,7 +63,6 @@ class FileSystemURLRequestJob : public net::URLRequestJob { FilePath relative_file_path_; FilePath absolute_file_path_; - GURL origin_url_; FileSystemPathManager* const path_manager_; net::CompletionCallbackImpl<FileSystemURLRequestJob> io_callback_; @@ -67,7 +71,6 @@ class FileSystemURLRequestJob : public net::URLRequestJob { net::HttpByteRange byte_range_; int64 remaining_bytes_; - int startup_error_; ScopedRunnableMethodFactory<FileSystemURLRequestJob> method_factory_; base::ScopedCallbackFactory<FileSystemURLRequestJob> callback_factory_; diff --git a/webkit/fileapi/file_system_url_request_job_unittest.cc b/webkit/fileapi/file_system_url_request_job_unittest.cc index 3e76338..c7db1f9 100644 --- a/webkit/fileapi/file_system_url_request_job_unittest.cc +++ b/webkit/fileapi/file_system_url_request_job_unittest.cc @@ -220,7 +220,6 @@ TEST_F(FileSystemURLRequestJobTest, FileTestMultipleRangesNotSupported) { headers.SetHeader(net::HttpRequestHeaders::kRange, "bytes=0-5,10-200,200-300"); TestRequestWithHeaders(CreateFileSystemURL("file1.dat"), &headers); - ASSERT_FALSE(request_->is_pending()); EXPECT_TRUE(delegate_->request_failed()); EXPECT_EQ(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE, request_->status().os_error()); |