| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/child/fileapi/webfilesystem_callback_adapters.h" | 5 #include "content/child/fileapi/webfilesystem_callback_adapters.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 void FileStatusCallbackAdapter( | 29 void FileStatusCallbackAdapter( |
| 30 WebKit::WebFileSystemCallbacks* callbacks, | 30 WebKit::WebFileSystemCallbacks* callbacks, |
| 31 base::PlatformFileError error) { | 31 base::PlatformFileError error) { |
| 32 if (error == base::PLATFORM_FILE_OK) | 32 if (error == base::PLATFORM_FILE_OK) |
| 33 callbacks->didSucceed(); | 33 callbacks->didSucceed(); |
| 34 else | 34 else |
| 35 callbacks->didFail(::fileapi::PlatformFileErrorToWebFileError(error)); | 35 callbacks->didFail(::fileapi::PlatformFileErrorToWebFileError(error)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void ReadMetadataCallbackAdapter( | |
| 39 WebKit::WebFileSystemCallbacks* callbacks, | |
| 40 const base::PlatformFileInfo& file_info) { | |
| 41 WebFileInfo web_file_info; | |
| 42 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); | |
| 43 callbacks->didReadMetadata(web_file_info); | |
| 44 } | |
| 45 | |
| 46 void CreateSnapshotFileCallbackAdapter( | |
| 47 WebKit::WebFileSystemCallbacks* callbacks, | |
| 48 const base::PlatformFileInfo& file_info, | |
| 49 const base::FilePath& platform_path) { | |
| 50 WebFileInfo web_file_info; | |
| 51 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); | |
| 52 web_file_info.platformPath = platform_path.AsUTF16Unsafe(); | |
| 53 callbacks->didCreateSnapshotFile(web_file_info); | |
| 54 } | |
| 55 | |
| 56 void ReadDirectoryCallbackAdapater( | |
| 57 WebKit::WebFileSystemCallbacks* callbacks, | |
| 58 const std::vector<fileapi::DirectoryEntry>& entries, | |
| 59 bool has_more) { | |
| 60 WebVector<WebFileSystemEntry> file_system_entries(entries.size()); | |
| 61 for (size_t i = 0; i < entries.size(); i++) { | |
| 62 file_system_entries[i].name = | |
| 63 base::FilePath(entries[i].name).AsUTF16Unsafe(); | |
| 64 file_system_entries[i].isDirectory = entries[i].is_directory; | |
| 65 } | |
| 66 callbacks->didReadDirectory(file_system_entries, has_more); | |
| 67 } | |
| 68 | |
| 69 void OpenFileSystemCallbackAdapter( | 38 void OpenFileSystemCallbackAdapter( |
| 70 WebKit::WebFileSystemCallbacks* callbacks, | 39 WebKit::WebFileSystemCallbacks* callbacks, |
| 71 const std::string& name, const GURL& root) { | 40 const std::string& name, const GURL& root) { |
| 72 callbacks->didOpenFileSystem(UTF8ToUTF16(name), root); | 41 callbacks->didOpenFileSystem(UTF8ToUTF16(name), root); |
| 73 } | 42 } |
| 74 | 43 |
| 75 } // namespace content | 44 } // namespace content |
| OLD | NEW |