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" |
11 | 11 |
| 12 namespace base { |
12 class FilePath; | 13 class FilePath; |
13 | |
14 namespace base { | |
15 class SequencedTaskRunner; | 14 class SequencedTaskRunner; |
16 class Time; | 15 class Time; |
17 } | 16 } |
18 | 17 |
19 namespace fileapi { | 18 namespace fileapi { |
20 | 19 |
21 // Delegate for media transfer protocol (MTP) device to perform media device | 20 // Delegate for media transfer protocol (MTP) device to perform media device |
22 // isolated file system operations. Class that implements this delegate does | 21 // isolated file system operations. Class that implements this delegate does |
23 // the actual communication with the MTP device. ScopedMTPDeviceMapEntry class | 22 // the actual communication with the MTP device. ScopedMTPDeviceMapEntry class |
24 // manages the lifetime of the delegate via MTPDeviceMapService class. | 23 // manages the lifetime of the delegate via MTPDeviceMapService class. |
25 class MTPDeviceDelegate { | 24 class MTPDeviceDelegate { |
26 public: | 25 public: |
27 // Returns information about the given file path. | 26 // Returns information about the given file path. |
28 virtual base::PlatformFileError GetFileInfo( | 27 virtual base::PlatformFileError GetFileInfo( |
29 const FilePath& file_path, | 28 const base::FilePath& file_path, |
30 base::PlatformFileInfo* file_info) = 0; | 29 base::PlatformFileInfo* file_info) = 0; |
31 | 30 |
32 // Returns a pointer to a new instance of AbstractFileEnumerator to enumerate | 31 // 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 | 32 // 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 | 33 // caller, and its lifetime should not extend past when the current call |
35 // returns to the main media task runner thread. | 34 // returns to the main media task runner thread. |
36 virtual scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> | 35 virtual scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> |
37 CreateFileEnumerator(const FilePath& root, | 36 CreateFileEnumerator(const base::FilePath& root, |
38 bool recursive) = 0; | 37 bool recursive) = 0; |
39 | 38 |
40 // Updates the temporary snapshot file contents given by |local_path| with | 39 // Updates the temporary snapshot file contents given by |local_path| with |
41 // media file contents given by |device_file_path| and also returns the | 40 // media file contents given by |device_file_path| and also returns the |
42 // metadata of the temporary file. | 41 // metadata of the temporary file. |
43 virtual base::PlatformFileError CreateSnapshotFile( | 42 virtual base::PlatformFileError CreateSnapshotFile( |
44 const FilePath& device_file_path, | 43 const base::FilePath& device_file_path, |
45 const FilePath& local_path, | 44 const base::FilePath& local_path, |
46 base::PlatformFileInfo* file_info) = 0; | 45 base::PlatformFileInfo* file_info) = 0; |
47 | 46 |
48 // Called when the | 47 // Called when the |
49 // (1) Browser application is in shutdown mode (or) | 48 // (1) Browser application is in shutdown mode (or) |
50 // (2) Last extension using this MTP device is destroyed (or) | 49 // (2) Last extension using this MTP device is destroyed (or) |
51 // (3) Attached MTP device is removed (or) | 50 // (3) Attached MTP device is removed (or) |
52 // (4) User revoked the MTP device gallery permission. | 51 // (4) User revoked the MTP device gallery permission. |
53 // Ownership of |MTPDeviceDelegate| is handed off to the delegate | 52 // Ownership of |MTPDeviceDelegate| is handed off to the delegate |
54 // implementation class by this call. This function should take care of | 53 // implementation class by this call. This function should take care of |
55 // deleting itself on the right thread. This function should cancel all the | 54 // deleting itself on the right thread. This function should cancel all the |
56 // pending requests before posting any message to delete itself. | 55 // pending requests before posting any message to delete itself. |
57 // Called on the UI thread. | 56 // Called on the UI thread. |
58 virtual void CancelPendingTasksAndDeleteDelegate() = 0; | 57 virtual void CancelPendingTasksAndDeleteDelegate() = 0; |
59 | 58 |
60 protected: | 59 protected: |
61 // Always destruct this object via CancelPendingTasksAndDeleteDelegate(). | 60 // Always destruct this object via CancelPendingTasksAndDeleteDelegate(). |
62 virtual ~MTPDeviceDelegate() {} | 61 virtual ~MTPDeviceDelegate() {} |
63 }; | 62 }; |
64 | 63 |
65 } // namespace fileapi | 64 } // namespace fileapi |
66 | 65 |
67 #endif // WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_DELEGATE_H_ | 66 #endif // WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_DELEGATE_H_ |
OLD | NEW |