diff options
author | kerz@chromium.org <kerz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-20 22:19:17 +0000 |
---|---|---|
committer | kerz@chromium.org <kerz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-20 22:19:17 +0000 |
commit | eeed85c4662942e0c9e557d36fa0d26a938058e5 (patch) | |
tree | 3e6e267779cd0de15b1dfb8543e399023a4b1342 /webkit/fileapi/file_system_url_request_job.cc | |
parent | fe2534f1d0294dadd3bc915982ef378906a2be57 (diff) | |
download | chromium_src-eeed85c4662942e0c9e557d36fa0d26a938058e5.zip chromium_src-eeed85c4662942e0c9e557d36fa0d26a938058e5.tar.gz chromium_src-eeed85c4662942e0c9e557d36fa0d26a938058e5.tar.bz2 |
Merge 82266 - Fixed file/directory url resolution for external mount point provider.Per Eric's request, refactored FileSystemDirURLRequestJob and FileSystemURLRequestJob classes to resolve local file system through a new operation.BUG=chromium-os:14225TEST=added new test cases to FileSystemPathManagerTest.*, added FileSystemOperationTest.TestGetLocalFilePathSuccessReview URL: http://codereview.chromium.org/6864040
TBR=zelidrag@chromium.org
Review URL: http://codereview.chromium.org/6882102
git-svn-id: svn://svn.chromium.org/chrome/branches/742/src@82372 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_url_request_job.cc')
-rw-r--r-- | webkit/fileapi/file_system_url_request_job.cc | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/webkit/fileapi/file_system_url_request_job.cc b/webkit/fileapi/file_system_url_request_job.cc index 81f6939..6b4732a 100644 --- a/webkit/fileapi/file_system_url_request_job.cc +++ b/webkit/fileapi/file_system_url_request_job.cc @@ -50,18 +50,17 @@ static net::HttpResponseHeaders* CreateHttpResponseHeaders() { } FileSystemURLRequestJob::FileSystemURLRequestJob( - URLRequest* request, FileSystemPathManager* path_manager, + URLRequest* request, FileSystemContext* file_system_context, scoped_refptr<base::MessageLoopProxy> file_thread_proxy) - : URLRequestJob(request), - path_manager_(path_manager), + : FileSystemURLRequestJobBase(request, file_system_context, + file_thread_proxy), + ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), + ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST( io_callback_(this, &FileSystemURLRequestJob::DidRead)), stream_(NULL), is_directory_(false), - remaining_bytes_(0), - ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), - ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)), - file_thread_proxy_(file_thread_proxy) { + remaining_bytes_(0) { } FileSystemURLRequestJob::~FileSystemURLRequestJob() { @@ -82,7 +81,6 @@ void FileSystemURLRequestJob::Kill() { stream_->Close(); stream_.reset(NULL); } - URLRequestJob::Kill(); callback_factory_.RevokeAll(); } @@ -148,6 +146,12 @@ void FileSystemURLRequestJob::SetExtraRequestHeaders( } } +void FileSystemURLRequestJob::DidGetLocalPath(const FilePath& local_path) { + absolute_file_path_ = local_path; + base::FileUtilProxy::GetFileInfo(file_thread_proxy_, absolute_file_path_, + callback_factory_.NewCallback(&FileSystemURLRequestJob::DidResolve)); +} + void FileSystemURLRequestJob::GetResponseInfo(net::HttpResponseInfo* info) { if (response_info_.get()) *info = *response_info_; @@ -159,34 +163,6 @@ int FileSystemURLRequestJob::GetResponseCode() const { return URLRequestJob::GetResponseCode(); } -void FileSystemURLRequestJob::StartAsync() { - GURL origin_url; - FileSystemType 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 - callback_factory_.NewCallback(&FileSystemURLRequestJob::DidGetRootPath)); -} - -void FileSystemURLRequestJob::DidGetRootPath(bool success, - const FilePath& root_path, - const std::string& name) { - if (!success) { - NotifyFailed(net::ERR_FILE_NOT_FOUND); - return; - } - - absolute_file_path_ = root_path.Append(relative_file_path_); - - base::FileUtilProxy::GetFileInfo(file_thread_proxy_, absolute_file_path_, - callback_factory_.NewCallback(&FileSystemURLRequestJob::DidResolve)); -} - void FileSystemURLRequestJob::DidResolve(base::PlatformFileError error_code, const base::PlatformFileInfo& file_info) { // We may have been orphaned... @@ -231,6 +207,9 @@ void FileSystemURLRequestJob::DidOpen(base::PlatformFileError error_code, byte_range_.first_byte_position() + 1; DCHECK_GE(remaining_bytes_, 0); + // TODO(adamk): Please remove this ScopedAllowIO once we support async seek on + // FileStream. + base::ThreadRestrictions::ScopedAllowIO allow_io; // Do the seek at the beginning of the request. if (remaining_bytes_ > 0 && byte_range_.first_byte_position() != 0 && @@ -278,8 +257,4 @@ bool FileSystemURLRequestJob::IsRedirectResponse(GURL* location, return false; } -void FileSystemURLRequestJob::NotifyFailed(int rv) { - NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); -} - } // namespace fileapi |