Commit df3bc522 authored by kinuko@chromium.org's avatar kinuko@chromium.org

Use the new CreateSnapshotFile() in FileSystemURLRequest job

BUG=115603
TEST=existing tests

Review URL: https://chromiumcodereview.appspot.com/9562032

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124694 0039d316-1c4b-4281-b951-d872f2087c98
parent 9ec09903
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "net/http/http_response_info.h" #include "net/http/http_response_info.h"
#include "net/http/http_util.h" #include "net/http/http_util.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
#include "webkit/blob/shareable_file_reference.h"
#include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_operation.h" #include "webkit/fileapi/file_system_operation.h"
#include "webkit/fileapi/file_system_util.h" #include "webkit/fileapi/file_system_util.h"
...@@ -181,15 +182,16 @@ void FileSystemURLRequestJob::StartAsync() { ...@@ -181,15 +182,16 @@ void FileSystemURLRequestJob::StartAsync() {
net::ERR_INVALID_URL)); net::ERR_INVALID_URL));
return; return;
} }
operation->GetMetadata( operation->CreateSnapshotFile(
request_->url(), request_->url(),
base::Bind(&FileSystemURLRequestJob::DidGetMetadata, this)); base::Bind(&FileSystemURLRequestJob::DidCreateSnapshot, this));
} }
void FileSystemURLRequestJob::DidGetMetadata( void FileSystemURLRequestJob::DidCreateSnapshot(
base::PlatformFileError error_code, base::PlatformFileError error_code,
const base::PlatformFileInfo& file_info, const base::PlatformFileInfo& file_info,
const FilePath& platform_path) { const FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
if (error_code != base::PLATFORM_FILE_OK) { if (error_code != base::PLATFORM_FILE_OK) {
NotifyFailed(error_code == base::PLATFORM_FILE_ERROR_INVALID_URL ? NotifyFailed(error_code == base::PLATFORM_FILE_ERROR_INVALID_URL ?
net::ERR_INVALID_URL : net::ERR_FILE_NOT_FOUND); net::ERR_INVALID_URL : net::ERR_FILE_NOT_FOUND);
...@@ -202,6 +204,9 @@ void FileSystemURLRequestJob::DidGetMetadata( ...@@ -202,6 +204,9 @@ void FileSystemURLRequestJob::DidGetMetadata(
is_directory_ = file_info.is_directory; is_directory_ = file_info.is_directory;
// Keep the reference (if it's non-null) so that the file won't go away.
snapshot_ref_ = file_ref;
if (!byte_range_.ComputeBounds(file_info.size)) { if (!byte_range_.ComputeBounds(file_info.size)) {
NotifyFailed(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE); NotifyFailed(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE);
return; return;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <string> #include <string>
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/message_loop_proxy.h" #include "base/message_loop_proxy.h"
...@@ -22,6 +23,10 @@ namespace net { ...@@ -22,6 +23,10 @@ namespace net {
class FileStream; class FileStream;
} }
namespace webkit_blob {
class ShareableFileReference;
}
namespace fileapi { namespace fileapi {
class FileSystemContext; class FileSystemContext;
...@@ -55,9 +60,11 @@ class FileSystemURLRequestJob : public net::URLRequestJob { ...@@ -55,9 +60,11 @@ class FileSystemURLRequestJob : public net::URLRequestJob {
virtual ~FileSystemURLRequestJob(); virtual ~FileSystemURLRequestJob();
void StartAsync(); void StartAsync();
void DidGetMetadata(base::PlatformFileError error_code, void DidCreateSnapshot(
const base::PlatformFileInfo& file_info, base::PlatformFileError error_code,
const FilePath& platform_path); const base::PlatformFileInfo& file_info,
const FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
void DidOpen(base::PlatformFileError error_code, void DidOpen(base::PlatformFileError error_code,
base::PassPlatformFile file, bool created); base::PassPlatformFile file, bool created);
void DidRead(int result); void DidRead(int result);
...@@ -67,6 +74,7 @@ class FileSystemURLRequestJob : public net::URLRequestJob { ...@@ -67,6 +74,7 @@ class FileSystemURLRequestJob : public net::URLRequestJob {
scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; scoped_refptr<base::MessageLoopProxy> file_thread_proxy_;
base::WeakPtrFactory<FileSystemURLRequestJob> weak_factory_; base::WeakPtrFactory<FileSystemURLRequestJob> weak_factory_;
scoped_ptr<net::FileStream> stream_; scoped_ptr<net::FileStream> stream_;
scoped_refptr<webkit_blob::ShareableFileReference> snapshot_ref_;
bool is_directory_; bool is_directory_;
scoped_ptr<net::HttpResponseInfo> response_info_; scoped_ptr<net::HttpResponseInfo> response_info_;
int64 remaining_bytes_; int64 remaining_bytes_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment