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

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: updated 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
« no previous file with comments | « webkit/fileapi/file_system_url_request_job.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>& file_ref) {
193 if (error_code != base::PLATFORM_FILE_OK) { 195 if (error_code != base::PLATFORM_FILE_OK) {
194 NotifyFailed(error_code == base::PLATFORM_FILE_ERROR_INVALID_URL ? 196 NotifyFailed(error_code == base::PLATFORM_FILE_ERROR_INVALID_URL ?
195 net::ERR_INVALID_URL : net::ERR_FILE_NOT_FOUND); 197 net::ERR_INVALID_URL : net::ERR_FILE_NOT_FOUND);
196 return; 198 return;
197 } 199 }
198 200
199 // We may have been orphaned... 201 // We may have been orphaned...
200 if (!request_) 202 if (!request_)
201 return; 203 return;
202 204
203 is_directory_ = file_info.is_directory; 205 is_directory_ = file_info.is_directory;
204 206
207 // Keep the reference (if it's non-null) so that the file won't go away.
208 snapshot_ref_ = file_ref;
209
205 if (!byte_range_.ComputeBounds(file_info.size)) { 210 if (!byte_range_.ComputeBounds(file_info.size)) {
206 NotifyFailed(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE); 211 NotifyFailed(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE);
207 return; 212 return;
208 } 213 }
209 214
210 if (!is_directory_) { 215 if (!is_directory_) {
211 base::FileUtilProxy::CreateOrOpen( 216 base::FileUtilProxy::CreateOrOpen(
212 file_thread_proxy_, platform_path, kFileFlags, 217 file_thread_proxy_, platform_path, kFileFlags,
213 base::Bind(&FileSystemURLRequestJob::DidOpen, 218 base::Bind(&FileSystemURLRequestJob::DidOpen,
214 weak_factory_.GetWeakPtr())); 219 weak_factory_.GetWeakPtr()));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 284 }
280 285
281 return false; 286 return false;
282 } 287 }
283 288
284 void FileSystemURLRequestJob::NotifyFailed(int rv) { 289 void FileSystemURLRequestJob::NotifyFailed(int rv) {
285 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); 290 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
286 } 291 }
287 292
288 } // namespace fileapi 293 } // namespace fileapi
OLDNEW
« no previous file with comments | « 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