summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_url_request_job.cc
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/fileapi/file_system_url_request_job.cc')
-rw-r--r--webkit/fileapi/file_system_url_request_job.cc55
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