| OLD | NEW |
| 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/tools/test_shell/simple_file_system.h" | 5 #include "webkit/tools/test_shell/simple_file_system.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 #include "net/base/mime_util.h" | 14 #include "net/base/mime_util.h" |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebFileInfo.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebFileInfo.h" |
| 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
| 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback
s.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback
s.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemEntry.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemEntry.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 22 #include "webkit/base/file_path_string_conversions.h" | 22 #include "webkit/base/file_path_string_conversions.h" |
| 23 #include "webkit/blob/blob_storage_controller.h" | 23 #include "webkit/blob/blob_storage_controller.h" |
| 24 #include "webkit/fileapi/directory_entry.h" |
| 24 #include "webkit/fileapi/file_permission_policy.h" | 25 #include "webkit/fileapi/file_permission_policy.h" |
| 25 #include "webkit/fileapi/file_system_mount_point_provider.h" | 26 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 26 #include "webkit/fileapi/file_system_url.h" | 27 #include "webkit/fileapi/file_system_url.h" |
| 27 #include "webkit/fileapi/file_system_util.h" | 28 #include "webkit/fileapi/file_system_util.h" |
| 28 #include "webkit/fileapi/mock_file_system_context.h" | 29 #include "webkit/fileapi/mock_file_system_context.h" |
| 29 #include "webkit/tools/test_shell/simple_file_writer.h" | 30 #include "webkit/tools/test_shell/simple_file_writer.h" |
| 30 | 31 |
| 31 using base::WeakPtr; | 32 using base::WeakPtr; |
| 32 | 33 |
| 33 using WebKit::WebFileInfo; | 34 using WebKit::WebFileInfo; |
| 34 using WebKit::WebFileSystem; | 35 using WebKit::WebFileSystem; |
| 35 using WebKit::WebFileSystemCallbacks; | 36 using WebKit::WebFileSystemCallbacks; |
| 36 using WebKit::WebFileSystemEntry; | 37 using WebKit::WebFileSystemEntry; |
| 37 using WebKit::WebFileWriter; | 38 using WebKit::WebFileWriter; |
| 38 using WebKit::WebFileWriterClient; | 39 using WebKit::WebFileWriterClient; |
| 39 using WebKit::WebFrame; | 40 using WebKit::WebFrame; |
| 40 using WebKit::WebString; | 41 using WebKit::WebString; |
| 41 using WebKit::WebURL; | 42 using WebKit::WebURL; |
| 42 using WebKit::WebVector; | 43 using WebKit::WebVector; |
| 43 | 44 |
| 44 using webkit_blob::BlobData; | 45 using webkit_blob::BlobData; |
| 45 using webkit_blob::BlobStorageController; | 46 using webkit_blob::BlobStorageController; |
| 47 using fileapi::DirectoryEntry; |
| 46 using fileapi::FileSystemContext; | 48 using fileapi::FileSystemContext; |
| 47 using fileapi::FileSystemOperation; | 49 using fileapi::FileSystemOperation; |
| 48 using fileapi::FileSystemTaskRunners; | 50 using fileapi::FileSystemTaskRunners; |
| 49 using fileapi::FileSystemURL; | 51 using fileapi::FileSystemURL; |
| 50 | 52 |
| 51 namespace { | 53 namespace { |
| 52 MessageLoop* g_io_thread; | 54 MessageLoop* g_io_thread; |
| 53 webkit_blob::BlobStorageController* g_blob_storage_controller; | 55 webkit_blob::BlobStorageController* g_blob_storage_controller; |
| 54 | 56 |
| 55 void RegisterBlob(const GURL& blob_url, const base::FilePath& file_path) { | 57 void RegisterBlob(const GURL& blob_url, const base::FilePath& file_path) { |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 webkit_base::FilePathToWebString(platform_path); | 338 webkit_base::FilePathToWebString(platform_path); |
| 337 callbacks->didReadMetadata(web_file_info); | 339 callbacks->didReadMetadata(web_file_info); |
| 338 } else { | 340 } else { |
| 339 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result)); | 341 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result)); |
| 340 } | 342 } |
| 341 } | 343 } |
| 342 | 344 |
| 343 void SimpleFileSystem::DidReadDirectory( | 345 void SimpleFileSystem::DidReadDirectory( |
| 344 WebFileSystemCallbacks* callbacks, | 346 WebFileSystemCallbacks* callbacks, |
| 345 base::PlatformFileError result, | 347 base::PlatformFileError result, |
| 346 const std::vector<base::FileUtilProxy::Entry>& entries, | 348 const std::vector<DirectoryEntry>& entries, |
| 347 bool has_more) { | 349 bool has_more) { |
| 348 if (result == base::PLATFORM_FILE_OK) { | 350 if (result == base::PLATFORM_FILE_OK) { |
| 349 std::vector<WebFileSystemEntry> web_entries_vector; | 351 std::vector<WebFileSystemEntry> web_entries_vector; |
| 350 for (std::vector<base::FileUtilProxy::Entry>::const_iterator it = | 352 for (std::vector<DirectoryEntry>::const_iterator it = entries.begin(); |
| 351 entries.begin(); it != entries.end(); ++it) { | 353 it != entries.end(); ++it) { |
| 352 WebFileSystemEntry entry; | 354 WebFileSystemEntry entry; |
| 353 entry.name = webkit_base::FilePathStringToWebString(it->name); | 355 entry.name = webkit_base::FilePathStringToWebString(it->name); |
| 354 entry.isDirectory = it->is_directory; | 356 entry.isDirectory = it->is_directory; |
| 355 web_entries_vector.push_back(entry); | 357 web_entries_vector.push_back(entry); |
| 356 } | 358 } |
| 357 WebVector<WebKit::WebFileSystemEntry> web_entries = web_entries_vector; | 359 WebVector<WebKit::WebFileSystemEntry> web_entries = web_entries_vector; |
| 358 callbacks->didReadDirectory(web_entries, has_more); | 360 callbacks->didReadDirectory(web_entries, has_more); |
| 359 } else { | 361 } else { |
| 360 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result)); | 362 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result)); |
| 361 } | 363 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 web_file_info.modificationTime = info.last_modified.ToDoubleT(); | 398 web_file_info.modificationTime = info.last_modified.ToDoubleT(); |
| 397 web_file_info.type = info.is_directory ? | 399 web_file_info.type = info.is_directory ? |
| 398 WebFileInfo::TypeDirectory : WebFileInfo::TypeFile; | 400 WebFileInfo::TypeDirectory : WebFileInfo::TypeFile; |
| 399 web_file_info.platformPath = | 401 web_file_info.platformPath = |
| 400 webkit_base::FilePathToWebString(platform_path); | 402 webkit_base::FilePathToWebString(platform_path); |
| 401 callbacks->didCreateSnapshotFile(web_file_info); | 403 callbacks->didCreateSnapshotFile(web_file_info); |
| 402 } else { | 404 } else { |
| 403 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result)); | 405 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result)); |
| 404 } | 406 } |
| 405 } | 407 } |
| OLD | NEW |