| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/common/fileapi/webfilesystem_callback_adapters.h" | |
| 6 | |
| 7 #include <string> | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/logging.h" | |
| 11 #include "base/utf_string_conversions.h" | |
| 12 #include "googleurl/src/gurl.h" | |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebFileInfo.h" | |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback
s.h" | |
| 16 #include "webkit/base/file_path_string_conversions.h" | |
| 17 #include "webkit/fileapi/directory_entry.h" | |
| 18 #include "webkit/fileapi/file_system_util.h" | |
| 19 #include "webkit/glue/webkit_glue.h" | |
| 20 | |
| 21 using WebKit::WebFileInfo; | |
| 22 using WebKit::WebFileSystemCallbacks; | |
| 23 using WebKit::WebFileSystemEntry; | |
| 24 using WebKit::WebString; | |
| 25 using WebKit::WebVector; | |
| 26 | |
| 27 namespace content { | |
| 28 | |
| 29 void FileStatusCallbackAdapter( | |
| 30 WebKit::WebFileSystemCallbacks* callbacks, | |
| 31 base::PlatformFileError error) { | |
| 32 if (error == base::PLATFORM_FILE_OK) | |
| 33 callbacks->didSucceed(); | |
| 34 else | |
| 35 callbacks->didFail(::fileapi::PlatformFileErrorToWebFileError(error)); | |
| 36 } | |
| 37 | |
| 38 void ReadMetadataCallbackAdapter( | |
| 39 WebKit::WebFileSystemCallbacks* callbacks, | |
| 40 const base::PlatformFileInfo& file_info, | |
| 41 const base::FilePath& platform_path) { | |
| 42 WebFileInfo web_file_info; | |
| 43 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); | |
| 44 web_file_info.platformPath = webkit_base::FilePathToWebString(platform_path); | |
| 45 callbacks->didReadMetadata(web_file_info); | |
| 46 } | |
| 47 | |
| 48 void CreateSnapshotFileCallbackAdapter( | |
| 49 WebKit::WebFileSystemCallbacks* callbacks, | |
| 50 const base::PlatformFileInfo& file_info, | |
| 51 const base::FilePath& platform_path) { | |
| 52 WebFileInfo web_file_info; | |
| 53 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); | |
| 54 web_file_info.platformPath = webkit_base::FilePathToWebString(platform_path); | |
| 55 callbacks->didCreateSnapshotFile(web_file_info); | |
| 56 } | |
| 57 | |
| 58 void ReadDirectoryCallbackAdapater( | |
| 59 WebKit::WebFileSystemCallbacks* callbacks, | |
| 60 const std::vector<fileapi::DirectoryEntry>& entries, | |
| 61 bool has_more) { | |
| 62 WebVector<WebFileSystemEntry> file_system_entries(entries.size()); | |
| 63 for (size_t i = 0; i < entries.size(); i++) { | |
| 64 file_system_entries[i].name = | |
| 65 webkit_base::FilePathStringToWebString(entries[i].name); | |
| 66 file_system_entries[i].isDirectory = entries[i].is_directory; | |
| 67 } | |
| 68 callbacks->didReadDirectory(file_system_entries, has_more); | |
| 69 } | |
| 70 | |
| 71 void OpenFileSystemCallbackAdapter( | |
| 72 WebKit::WebFileSystemCallbacks* callbacks, | |
| 73 const std::string& name, const GURL& root) { | |
| 74 callbacks->didOpenFileSystem(UTF8ToUTF16(name), root); | |
| 75 } | |
| 76 | |
| 77 } // namespace content | |
| OLD | NEW |