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 #ifndef WEBKIT_FILEAPI_MEDIA_FILE_SYSTEM_PROXY_WIN_H_ |
| 6 #define WEBKIT_FILEAPI_MEDIA_FILE_SYSTEM_PROXY_WIN_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <vector> |
| 10 |
| 11 #include <PortableDeviceApi.h> // Include this header for Windows Portable Devi
ce API interfaces |
| 12 #include <PortableDevice.h> // Include this header for Windows Portable Devi
ce definitions |
| 13 |
| 14 #include "base/callback.h" |
| 15 #include "base/file_path.h" |
| 16 #include "base/file_util_proxy.h" |
| 17 #include "base/platform_file.h" |
| 18 #include "webkit/fileapi/media_file_system_proxy.h" |
| 19 #include "base/win/scoped_comptr.h" |
| 20 |
| 21 |
| 22 class GURL; |
| 23 |
| 24 using base::PlatformFileError; |
| 25 |
| 26 namespace fileapi { |
| 27 |
| 28 class FileSystemOperationContext; |
| 29 |
| 30 // The interface class for media file system proxy. |
| 31 class MediaFileSystemProxyWin : public fileapi::MediaFileSystemProxyInterface { |
| 32 public: |
| 33 // Some of the proxy routines are just wrapping around the FileUtilProxy's |
| 34 // relay methods, so we use the same types as FileUtilProxy for them. |
| 35 typedef base::FileUtilProxy::Entry Entry; |
| 36 typedef base::Callback<void(PlatformFileError, |
| 37 const std::vector<Entry>&, |
| 38 bool has_more)> ReadDirectoryCallback; |
| 39 |
| 40 MediaFileSystemProxyWin(const FilePath::StringType& device_id); |
| 41 ~MediaFileSystemProxyWin(); |
| 42 |
| 43 // Gets the file or directory info for given|path|. |
| 44 virtual void GetFileInfo(const FileSystemURL& url, |
| 45 const FileSystemOperationInterface::GetMetadataCallback& callback); |
| 46 |
| 47 // Copies a file or directory from |src_url| to |dest_url|. If |
| 48 // |src_url| is a directory, the contents of |src_url| are copied to |
| 49 // |dest_url| recursively. A new file or directory is created at |
| 50 // |dest_url| as needed. |
| 51 virtual void Copy( |
| 52 const FileSystemURL& src_url, |
| 53 const FileSystemURL& dest_url, |
| 54 const FileSystemOperationInterface::StatusCallback& callback); |
| 55 |
| 56 // Moves a file or directory from |src_url| to |dest_url|. A new file |
| 57 // or directory is created at |dest_url| as needed. |
| 58 virtual void Move( |
| 59 const FileSystemURL& src_url, |
| 60 const FileSystemURL& dest_url, |
| 61 const FileSystemOperationInterface::StatusCallback& callback); |
| 62 |
| 63 // Reads contents of a directory at |url|. |
| 64 virtual void ReadDirectory( |
| 65 FileSystemOperationContext* context, |
| 66 const FileSystemURL& url, |
| 67 const FileSystemOperationInterface::ReadDirectoryCallback& callback); |
| 68 |
| 69 // Removes a file or directory at |url|. If |recursive| is true, remove |
| 70 // all files and directories under the directory at |url| recursively. |
| 71 virtual void Remove(const FileSystemURL& url, bool recursive, |
| 72 const FileSystemOperationInterface::StatusCallback& callback); |
| 73 |
| 74 // Creates a directory at |url|. If |exclusive| is true, an error is |
| 75 // raised in case a directory is already present at the URL. If |
| 76 // |recursive| is true, create parent directories as needed just like |
| 77 // mkdir -p does. |
| 78 virtual void CreateDirectory( |
| 79 const FileSystemURL& url, |
| 80 bool exclusive, |
| 81 bool recursive, |
| 82 const FileSystemOperationInterface::StatusCallback& callback); |
| 83 |
| 84 // Creates a file at |url|. If the flag |is_exclusive| is true, an |
| 85 // error is raised when a file already exists at the path. It is |
| 86 // an error if a directory or a hosted document is already present at the |
| 87 // path, or the parent directory of the path is not present yet. |
| 88 virtual void CreateFile( |
| 89 const FileSystemURL& url, |
| 90 bool exclusive, |
| 91 const FileSystemOperationInterface::StatusCallback& callback); |
| 92 |
| 93 // Opens file for a give |url| with specified |flags| (see |
| 94 // base::PlatformFileFlags for details). |
| 95 virtual void OpenFile( |
| 96 const FileSystemURL& url, |
| 97 int flags, |
| 98 base::ProcessHandle peer_handle, |
| 99 const FileSystemOperationInterface::OpenFileCallback& callback); |
| 100 |
| 101 // Notifies that a file opened by OpenFile (at |path|) is closed. |
| 102 virtual void NotifyCloseFile(const FileSystemURL& url); |
| 103 |
| 104 private: |
| 105 // Store a map of entry full path with the corresponding object id in the devi
ce. |
| 106 // Key: Entry.FullPath |
| 107 // Value: Object identifier specified by the device. |
| 108 typedef std::map<std::string, std::string> ObjectIdMap; |
| 109 |
| 110 // MTP Device identifier. |
| 111 FilePath::StringType device_id_; |
| 112 |
| 113 ObjectIdMap object_id_map_; |
| 114 base::win::ScopedComPtr<IPortableDevice> portable_device_; |
| 115 }; |
| 116 |
| 117 } // namespace fileapi |
| 118 |
| 119 #endif // WEBKIT_FILEAPI_MEDIA_FILE_SYSTEM_PROXY_H_ |
OLD | NEW |