Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: webkit/fileapi/file_system_url_request_job.cc

Issue 9562032: Use the new CreateSnapshotFile() in FileSystemURLRequest job (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/fileapi/file_system_url_request_job.h" 5 #include "webkit/fileapi/file_system_url_request_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util_proxy.h" 10 #include "base/file_util_proxy.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/platform_file.h" 12 #include "base/platform_file.h"
13 #include "base/threading/thread_restrictions.h" 13 #include "base/threading/thread_restrictions.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 #include "net/base/file_stream.h" 16 #include "net/base/file_stream.h"
17 #include "net/base/io_buffer.h" 17 #include "net/base/io_buffer.h"
18 #include "net/base/mime_util.h" 18 #include "net/base/mime_util.h"
19 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
20 #include "net/base/net_util.h" 20 #include "net/base/net_util.h"
21 #include "net/http/http_response_headers.h" 21 #include "net/http/http_response_headers.h"
22 #include "net/http/http_response_info.h" 22 #include "net/http/http_response_info.h"
23 #include "net/http/http_util.h" 23 #include "net/http/http_util.h"
24 #include "net/url_request/url_request.h" 24 #include "net/url_request/url_request.h"
25 #include "webkit/blob/shareable_file_reference.h"
25 #include "webkit/fileapi/file_system_context.h" 26 #include "webkit/fileapi/file_system_context.h"
26 #include "webkit/fileapi/file_system_operation.h" 27 #include "webkit/fileapi/file_system_operation.h"
27 #include "webkit/fileapi/file_system_util.h" 28 #include "webkit/fileapi/file_system_util.h"
28 29
29 using net::URLRequest; 30 using net::URLRequest;
30 using net::URLRequestJob; 31 using net::URLRequestJob;
31 using net::URLRequestStatus; 32 using net::URLRequestStatus;
32 33
33 namespace fileapi { 34 namespace fileapi {
34 35
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 return; 175 return;
175 FileSystemOperationInterface* operation = 176 FileSystemOperationInterface* operation =
176 file_system_context_->CreateFileSystemOperation( 177 file_system_context_->CreateFileSystemOperation(
177 request_->url(), 178 request_->url(),
178 file_thread_proxy_); 179 file_thread_proxy_);
179 if (!operation) { 180 if (!operation) {
180 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, 181 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
181 net::ERR_INVALID_URL)); 182 net::ERR_INVALID_URL));
182 return; 183 return;
183 } 184 }
184 operation->GetMetadata( 185 operation->CreateSnapshotFile(
185 request_->url(), 186 request_->url(),
186 base::Bind(&FileSystemURLRequestJob::DidGetMetadata, this)); 187 base::Bind(&FileSystemURLRequestJob::DidCreateSnapshot, this));
187 } 188 }
188 189
189 void FileSystemURLRequestJob::DidGetMetadata( 190 void FileSystemURLRequestJob::DidCreateSnapshot(
190 base::PlatformFileError error_code, 191 base::PlatformFileError error_code,
191 const base::PlatformFileInfo& file_info, 192 const base::PlatformFileInfo& file_info,
192 const FilePath& platform_path) { 193 const FilePath& platform_path,
194 const scoped_refptr<webkit_blob::ShareableFileReference>&
195 deletable_file_ref) {
193 if (error_code != base::PLATFORM_FILE_OK) { 196 if (error_code != base::PLATFORM_FILE_OK) {
194 NotifyFailed(error_code == base::PLATFORM_FILE_ERROR_INVALID_URL ? 197 NotifyFailed(error_code == base::PLATFORM_FILE_ERROR_INVALID_URL ?
195 net::ERR_INVALID_URL : net::ERR_FILE_NOT_FOUND); 198 net::ERR_INVALID_URL : net::ERR_FILE_NOT_FOUND);
196 return; 199 return;
197 } 200 }
198 201
199 // We may have been orphaned... 202 // We may have been orphaned...
200 if (!request_) 203 if (!request_)
201 return; 204 return;
202 205
203 is_directory_ = file_info.is_directory; 206 is_directory_ = file_info.is_directory;
204 207
208 // Keep the reference (if it's non-null) so that the file won't go away.
209 snapshot_ref_ = deletable_file_ref;
210
205 if (!byte_range_.ComputeBounds(file_info.size)) { 211 if (!byte_range_.ComputeBounds(file_info.size)) {
206 NotifyFailed(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE); 212 NotifyFailed(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE);
207 return; 213 return;
208 } 214 }
209 215
210 if (!is_directory_) { 216 if (!is_directory_) {
211 base::FileUtilProxy::CreateOrOpen( 217 base::FileUtilProxy::CreateOrOpen(
212 file_thread_proxy_, platform_path, kFileFlags, 218 file_thread_proxy_, platform_path, kFileFlags,
213 base::Bind(&FileSystemURLRequestJob::DidOpen, 219 base::Bind(&FileSystemURLRequestJob::DidOpen,
214 weak_factory_.GetWeakPtr())); 220 weak_factory_.GetWeakPtr()));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 285 }
280 286
281 return false; 287 return false;
282 } 288 }
283 289
284 void FileSystemURLRequestJob::NotifyFailed(int rv) { 290 void FileSystemURLRequestJob::NotifyFailed(int rv) {
285 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); 291 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
286 } 292 }
287 293
288 } // namespace fileapi 294 } // namespace fileapi
OLDNEW
« webkit/fileapi/file_system_url_request_job.h ('K') | « webkit/fileapi/file_system_url_request_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698