Chromium Code Reviews| 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 #ifndef WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_DELEGATE_H_ | 5 #ifndef WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_DELEGATE_H_ |
|
darin (slow to review)
2013/01/30 05:51:03
I'm apparently quite late to the party, but I don'
kinuko
2013/01/30 07:12:55
Agreed, we're in a way of refactoring this part (a
| |
| 6 #define WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_DELEGATE_H_ | 6 #define WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/platform_file.h" | 9 #include "base/platform_file.h" |
| 10 #include "webkit/fileapi/file_system_file_util.h" | 10 #include "webkit/fileapi/file_system_file_util.h" |
| 11 | 11 |
| 12 class FilePath; | 12 class FilePath; |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class SequencedTaskRunner; | 15 class SequencedTaskRunner; |
| 16 class Time; | 16 class Time; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace fileapi { | 19 namespace fileapi { |
| 20 | 20 |
| 21 // Delegate for media transfer protocol (MTP) device to perform media device | 21 // Delegate for media transfer protocol (MTP) device to perform media device |
| 22 // isolated file system operations. Class that implements this delegate does | 22 // isolated file system operations. Class that implements this delegate does |
| 23 // the actual communication with the MTP device. ScopedMTPDeviceMapEntry class | 23 // the actual communication with the MTP device. ScopedMTPDeviceMapEntry class |
| 24 // manages the lifetime of the delegate via MTPDeviceMapService class. | 24 // manages the lifetime of the delegate via MTPDeviceMapService class. |
| 25 class MTPDeviceDelegate { | 25 class MTPDeviceDelegate { |
| 26 public: | 26 public: |
| 27 // Returns information about the given file path. | 27 // Returns information about the given file path. |
| 28 virtual base::PlatformFileError GetFileInfo( | 28 virtual base::PlatformFileError GetFileInfo( |
| 29 const FilePath& file_path, | 29 const FilePath& file_path, |
| 30 base::PlatformFileInfo* file_info) = 0; | 30 base::PlatformFileInfo* file_info) = 0; |
| 31 | 31 |
| 32 // Returns a pointer to a new instance of AbstractFileEnumerator to enumerate | 32 // Returns a pointer to a new instance of AbstractFileEnumerator to enumerate |
| 33 // the file entries of |root| path. The instance needs to be freed by the | 33 // the file entries of |root| path. The instance needs to be freed by the |
| 34 // caller, and its lifetime should not extend past when the current call | 34 // caller, and its lifetime should not extend past when the current call |
| 35 // returns to the main media task runner thread. | 35 // returns to the main media task runner thread. Callers must ensure the |
| 36 // lifetime of the enumerator is shorter than the MTPDeviceDelegate | |
| 37 // implementation itself. Calls to the enumerator are made in the context of | |
| 38 // a SeuqencedWorkerPool, and the enumerator may block while it is being | |
| 39 // called. | |
| 36 virtual scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> | 40 virtual scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> |
| 37 CreateFileEnumerator(const FilePath& root, | 41 CreateFileEnumerator(const FilePath& root, |
| 38 bool recursive) = 0; | 42 bool recursive) = 0; |
| 39 | 43 |
| 40 // Updates the temporary snapshot file contents given by |local_path| with | 44 // Updates the temporary snapshot file contents given by |local_path| with |
| 41 // media file contents given by |device_file_path| and also returns the | 45 // media file contents given by |device_file_path| and also returns the |
| 42 // metadata of the temporary file. | 46 // metadata of the temporary file. All calls to this interface method are |
| 47 // made in the context of a SequencedWorkerPool, and so only one call will be | |
| 48 // active at once. Implementations may block this pool. | |
| 43 virtual base::PlatformFileError CreateSnapshotFile( | 49 virtual base::PlatformFileError CreateSnapshotFile( |
| 44 const FilePath& device_file_path, | 50 const FilePath& device_file_path, |
| 45 const FilePath& local_path, | 51 const FilePath& local_path, |
| 46 base::PlatformFileInfo* file_info) = 0; | 52 base::PlatformFileInfo* file_info) = 0; |
| 47 | 53 |
| 48 // Called when the | 54 // Called when the |
| 49 // (1) Browser application is in shutdown mode (or) | 55 // (1) Browser application is in shutdown mode (or) |
| 50 // (2) Last extension using this MTP device is destroyed (or) | 56 // (2) Last extension using this MTP device is destroyed (or) |
| 51 // (3) Attached MTP device is removed (or) | 57 // (3) Attached MTP device is removed (or) |
| 52 // (4) User revoked the MTP device gallery permission. | 58 // (4) User revoked the MTP device gallery permission. |
| 53 // Ownership of |MTPDeviceDelegate| is handed off to the delegate | 59 // Ownership of |MTPDeviceDelegate| is handed off to the delegate |
| 54 // implementation class by this call. This function should take care of | 60 // implementation class by this call. This function should take care of |
| 55 // deleting itself on the right thread. This function should cancel all the | 61 // deleting itself on the right thread. This function should cancel all the |
| 56 // pending requests before posting any message to delete itself. | 62 // pending requests before posting any message to delete itself. |
| 57 // Called on the UI thread. | 63 // Called on the UI thread. |
| 58 virtual void CancelPendingTasksAndDeleteDelegate() = 0; | 64 virtual void CancelPendingTasksAndDeleteDelegate() = 0; |
| 59 | 65 |
| 60 protected: | 66 protected: |
| 61 // Always destruct this object via CancelPendingTasksAndDeleteDelegate(). | 67 // Always destruct this object via CancelPendingTasksAndDeleteDelegate(). |
| 62 virtual ~MTPDeviceDelegate() {} | 68 virtual ~MTPDeviceDelegate() {} |
| 63 }; | 69 }; |
| 64 | 70 |
| 65 } // namespace fileapi | 71 } // namespace fileapi |
| 66 | 72 |
| 67 #endif // WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_DELEGATE_H_ | 73 #endif // WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_DELEGATE_H_ |
| OLD | NEW |