OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_operation.h" | 5 #include "webkit/fileapi/file_system_operation.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "net/base/escape.h" | 10 #include "net/base/escape.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 if (!VerifyFileSystemPathForRead(path, &origin_url, &type, &virtual_path, | 303 if (!VerifyFileSystemPathForRead(path, &origin_url, &type, &virtual_path, |
304 &file_util)) { | 304 &file_util)) { |
305 delete this; | 305 delete this; |
306 return; | 306 return; |
307 } | 307 } |
308 file_system_operation_context_.set_src_origin_url(origin_url); | 308 file_system_operation_context_.set_src_origin_url(origin_url); |
309 file_system_operation_context_.set_src_type(type); | 309 file_system_operation_context_.set_src_type(type); |
310 if (!file_system_operation_context_.src_file_util()) | 310 if (!file_system_operation_context_.src_file_util()) |
311 file_system_operation_context_.set_src_file_util(file_util); | 311 file_system_operation_context_.set_src_file_util(file_util); |
312 FileSystemFileUtilProxy::GetFileInfo( | 312 FileSystemFileUtilProxy::GetFileInfo( |
313 file_system_operation_context_, | 313 file_system_operation_context_, proxy_, virtual_path, |
314 proxy_, virtual_path, callback_factory_.NewCallback( | 314 base::Bind(&FileSystemOperation::DidDirectoryExists, |
315 &FileSystemOperation::DidDirectoryExists)); | 315 weak_factory_.GetWeakPtr())); |
316 } | 316 } |
317 | 317 |
318 void FileSystemOperation::FileExists(const GURL& path) { | 318 void FileSystemOperation::FileExists(const GURL& path) { |
319 #ifndef NDEBUG | 319 #ifndef NDEBUG |
320 DCHECK(kOperationNone == pending_operation_); | 320 DCHECK(kOperationNone == pending_operation_); |
321 pending_operation_ = kOperationFileExists; | 321 pending_operation_ = kOperationFileExists; |
322 #endif | 322 #endif |
323 | 323 |
324 FilePath virtual_path; | 324 FilePath virtual_path; |
325 GURL origin_url; | 325 GURL origin_url; |
326 FileSystemType type; | 326 FileSystemType type; |
327 FileSystemFileUtil* file_util; | 327 FileSystemFileUtil* file_util; |
328 if (!VerifyFileSystemPathForRead(path, &origin_url, &type, &virtual_path, | 328 if (!VerifyFileSystemPathForRead(path, &origin_url, &type, &virtual_path, |
329 &file_util)) { | 329 &file_util)) { |
330 delete this; | 330 delete this; |
331 return; | 331 return; |
332 } | 332 } |
333 file_system_operation_context_.set_src_origin_url(origin_url); | 333 file_system_operation_context_.set_src_origin_url(origin_url); |
334 file_system_operation_context_.set_src_type(type); | 334 file_system_operation_context_.set_src_type(type); |
335 if (!file_system_operation_context_.src_file_util()) | 335 if (!file_system_operation_context_.src_file_util()) |
336 file_system_operation_context_.set_src_file_util(file_util); | 336 file_system_operation_context_.set_src_file_util(file_util); |
337 FileSystemFileUtilProxy::GetFileInfo( | 337 FileSystemFileUtilProxy::GetFileInfo( |
338 file_system_operation_context_, | 338 file_system_operation_context_, proxy_, virtual_path, |
339 proxy_, virtual_path, callback_factory_.NewCallback( | 339 base::Bind(&FileSystemOperation::DidFileExists, |
340 &FileSystemOperation::DidFileExists)); | 340 weak_factory_.GetWeakPtr())); |
341 } | 341 } |
342 | 342 |
343 void FileSystemOperation::GetMetadata(const GURL& path) { | 343 void FileSystemOperation::GetMetadata(const GURL& path) { |
344 #ifndef NDEBUG | 344 #ifndef NDEBUG |
345 DCHECK(kOperationNone == pending_operation_); | 345 DCHECK(kOperationNone == pending_operation_); |
346 pending_operation_ = kOperationGetMetadata; | 346 pending_operation_ = kOperationGetMetadata; |
347 #endif | 347 #endif |
348 | 348 |
349 FilePath virtual_path; | 349 FilePath virtual_path; |
350 GURL origin_url; | 350 GURL origin_url; |
351 FileSystemType type; | 351 FileSystemType type; |
352 FileSystemFileUtil* file_util; | 352 FileSystemFileUtil* file_util; |
353 if (!VerifyFileSystemPathForRead(path, &origin_url, &type, &virtual_path, | 353 if (!VerifyFileSystemPathForRead(path, &origin_url, &type, &virtual_path, |
354 &file_util)) { | 354 &file_util)) { |
355 delete this; | 355 delete this; |
356 return; | 356 return; |
357 } | 357 } |
358 file_system_operation_context_.set_src_origin_url(origin_url); | 358 file_system_operation_context_.set_src_origin_url(origin_url); |
359 file_system_operation_context_.set_src_type(type); | 359 file_system_operation_context_.set_src_type(type); |
360 if (!file_system_operation_context_.src_file_util()) | 360 if (!file_system_operation_context_.src_file_util()) |
361 file_system_operation_context_.set_src_file_util(file_util); | 361 file_system_operation_context_.set_src_file_util(file_util); |
362 FileSystemFileUtilProxy::GetFileInfo( | 362 FileSystemFileUtilProxy::GetFileInfo( |
363 file_system_operation_context_, | 363 file_system_operation_context_, proxy_, virtual_path, |
364 proxy_, virtual_path, callback_factory_.NewCallback( | 364 base::Bind(&FileSystemOperation::DidGetMetadata, |
365 &FileSystemOperation::DidGetMetadata)); | 365 weak_factory_.GetWeakPtr())); |
366 } | 366 } |
367 | 367 |
368 void FileSystemOperation::ReadDirectory(const GURL& path) { | 368 void FileSystemOperation::ReadDirectory(const GURL& path) { |
369 #ifndef NDEBUG | 369 #ifndef NDEBUG |
370 DCHECK(kOperationNone == pending_operation_); | 370 DCHECK(kOperationNone == pending_operation_); |
371 pending_operation_ = kOperationReadDirectory; | 371 pending_operation_ = kOperationReadDirectory; |
372 #endif | 372 #endif |
373 | 373 |
374 FilePath virtual_path; | 374 FilePath virtual_path; |
375 GURL origin_url; | 375 GURL origin_url; |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 return false; | 893 return false; |
894 } | 894 } |
895 DCHECK(file_util); | 895 DCHECK(file_util); |
896 *file_util = file_system_context()->path_manager()->GetFileUtil(*type); | 896 *file_util = file_system_context()->path_manager()->GetFileUtil(*type); |
897 DCHECK(*file_util); | 897 DCHECK(*file_util); |
898 | 898 |
899 return true; | 899 return true; |
900 } | 900 } |
901 | 901 |
902 } // namespace fileapi | 902 } // namespace fileapi |
OLD | NEW |