| 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_ |
| 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" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 class MTPDeviceDelegate { | 24 class MTPDeviceDelegate { |
| 25 public: | 25 public: |
| 26 // Returns information about the given file path. | 26 // Returns information about the given file path. |
| 27 virtual base::PlatformFileError GetFileInfo( | 27 virtual base::PlatformFileError GetFileInfo( |
| 28 const base::FilePath& file_path, | 28 const base::FilePath& file_path, |
| 29 base::PlatformFileInfo* file_info) = 0; | 29 base::PlatformFileInfo* file_info) = 0; |
| 30 | 30 |
| 31 // Returns a pointer to a new instance of AbstractFileEnumerator to enumerate | 31 // Returns a pointer to a new instance of AbstractFileEnumerator to enumerate |
| 32 // the file entries of |root| path. The instance needs to be freed by the | 32 // the file entries of |root| path. The instance needs to be freed by the |
| 33 // caller, and its lifetime should not extend past when the current call | 33 // caller, and its lifetime should not extend past when the current call |
| 34 // returns to the main media task runner thread. | 34 // returns to the main media task runner thread. Callers must ensure the |
| 35 // lifetime of the enumerator is shorter than the MTPDeviceDelegate |
| 36 // implementation itself. Calls to the enumerator are made in the context of |
| 37 // a SeuqencedWorkerPool, and the enumerator may block while it is being |
| 38 // called. |
| 35 virtual scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> | 39 virtual scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> |
| 36 CreateFileEnumerator(const base::FilePath& root, | 40 CreateFileEnumerator(const base::FilePath& root, |
| 37 bool recursive) = 0; | 41 bool recursive) = 0; |
| 38 | 42 |
| 39 // Updates the temporary snapshot file contents given by |local_path| with | 43 // Updates the temporary snapshot file contents given by |local_path| with |
| 40 // media file contents given by |device_file_path| and also returns the | 44 // media file contents given by |device_file_path| and also returns the |
| 41 // metadata of the temporary file. | 45 // metadata of the temporary file. All calls to this interface method are |
| 46 // made in the context of a SequencedWorkerPool, and so only one call will be |
| 47 // active at once. Implementations may block this pool. |
| 42 virtual base::PlatformFileError CreateSnapshotFile( | 48 virtual base::PlatformFileError CreateSnapshotFile( |
| 43 const base::FilePath& device_file_path, | 49 const base::FilePath& device_file_path, |
| 44 const base::FilePath& local_path, | 50 const base::FilePath& local_path, |
| 45 base::PlatformFileInfo* file_info) = 0; | 51 base::PlatformFileInfo* file_info) = 0; |
| 46 | 52 |
| 47 // Called when the | 53 // Called when the |
| 48 // (1) Browser application is in shutdown mode (or) | 54 // (1) Browser application is in shutdown mode (or) |
| 49 // (2) Last extension using this MTP device is destroyed (or) | 55 // (2) Last extension using this MTP device is destroyed (or) |
| 50 // (3) Attached MTP device is removed (or) | 56 // (3) Attached MTP device is removed (or) |
| 51 // (4) User revoked the MTP device gallery permission. | 57 // (4) User revoked the MTP device gallery permission. |
| 52 // Ownership of |MTPDeviceDelegate| is handed off to the delegate | 58 // Ownership of |MTPDeviceDelegate| is handed off to the delegate |
| 53 // implementation class by this call. This function should take care of | 59 // implementation class by this call. This function should take care of |
| 54 // deleting itself on the right thread. This function should cancel all the | 60 // deleting itself on the right thread. This function should cancel all the |
| 55 // pending requests before posting any message to delete itself. | 61 // pending requests before posting any message to delete itself. |
| 56 // Called on the UI thread. | 62 // Called on the UI thread. |
| 57 virtual void CancelPendingTasksAndDeleteDelegate() = 0; | 63 virtual void CancelPendingTasksAndDeleteDelegate() = 0; |
| 58 | 64 |
| 59 protected: | 65 protected: |
| 60 // Always destruct this object via CancelPendingTasksAndDeleteDelegate(). | 66 // Always destruct this object via CancelPendingTasksAndDeleteDelegate(). |
| 61 virtual ~MTPDeviceDelegate() {} | 67 virtual ~MTPDeviceDelegate() {} |
| 62 }; | 68 }; |
| 63 | 69 |
| 64 } // namespace fileapi | 70 } // namespace fileapi |
| 65 | 71 |
| 66 #endif // WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_DELEGATE_H_ | 72 #endif // WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_DELEGATE_H_ |
| OLD | NEW |