| 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 CHROME_BROWSER_MEDIA_GALLERY_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERY_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ |
| 6 #define CHROME_BROWSER_MEDIA_GALLERY_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERY_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
| 12 #include "base/sequenced_task_runner_helpers.h" | 12 #include "base/sequenced_task_runner_helpers.h" |
| 13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 14 #include "chrome/browser/media_gallery/mtp_device_delegate_impl.h" | 14 #include "chrome/browser/media_gallery/mtp_device_delegate_impl.h" |
| 15 #include "webkit/fileapi/file_system_file_util.h" | 15 #include "webkit/fileapi/file_system_file_util.h" |
| 16 #include "webkit/fileapi/media/mtp_device_delegate.h" | 16 #include "webkit/fileapi/media/mtp_device_delegate.h" |
| 17 | 17 |
| 18 namespace base { |
| 18 class FilePath; | 19 class FilePath; |
| 19 | |
| 20 namespace base { | |
| 21 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
| 22 } | 21 } |
| 23 | 22 |
| 24 namespace chrome { | 23 namespace chrome { |
| 25 | 24 |
| 26 // This class communicates with the MTP storage to complete the isolated file | 25 // This class communicates with the MTP storage to complete the isolated file |
| 27 // system operations. This class contains platform specific code to communicate | 26 // system operations. This class contains platform specific code to communicate |
| 28 // with the attached MTP storage. | 27 // with the attached MTP storage. |
| 29 // Instantiate this class per MTP storage using CreateMTPDeviceDelegate(). | 28 // Instantiate this class per MTP storage using CreateMTPDeviceDelegate(). |
| 30 // This object lives on a sequenced task runner thread, except for | 29 // This object lives on a sequenced task runner thread, except for |
| (...skipping 14 matching lines...) Expand all Loading... |
| 45 // Destructed via CancelPendingTasksAndDeleteDelegate(). | 44 // Destructed via CancelPendingTasksAndDeleteDelegate(). |
| 46 virtual ~MTPDeviceDelegateImplLinux(); | 45 virtual ~MTPDeviceDelegateImplLinux(); |
| 47 | 46 |
| 48 // Opens the device for communication. This function is called on | 47 // Opens the device for communication. This function is called on |
| 49 // |media_task_runner_|. Returns true if the device is ready for | 48 // |media_task_runner_|. Returns true if the device is ready for |
| 50 // communication, else false. | 49 // communication, else false. |
| 51 bool LazyInit(); | 50 bool LazyInit(); |
| 52 | 51 |
| 53 // MTPDeviceDelegate: | 52 // MTPDeviceDelegate: |
| 54 virtual base::PlatformFileError GetFileInfo( | 53 virtual base::PlatformFileError GetFileInfo( |
| 55 const FilePath& file_path, | 54 const base::FilePath& file_path, |
| 56 base::PlatformFileInfo* file_info) OVERRIDE; | 55 base::PlatformFileInfo* file_info) OVERRIDE; |
| 57 virtual scoped_ptr<fileapi::FileSystemFileUtil::AbstractFileEnumerator> | 56 virtual scoped_ptr<fileapi::FileSystemFileUtil::AbstractFileEnumerator> |
| 58 CreateFileEnumerator(const FilePath& root, | 57 CreateFileEnumerator(const base::FilePath& root, |
| 59 bool recursive) OVERRIDE; | 58 bool recursive) OVERRIDE; |
| 60 virtual base::PlatformFileError CreateSnapshotFile( | 59 virtual base::PlatformFileError CreateSnapshotFile( |
| 61 const FilePath& device_file_path, | 60 const base::FilePath& device_file_path, |
| 62 const FilePath& local_path, | 61 const base::FilePath& local_path, |
| 63 base::PlatformFileInfo* file_info) OVERRIDE; | 62 base::PlatformFileInfo* file_info) OVERRIDE; |
| 64 virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE; | 63 virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE; |
| 65 | 64 |
| 66 // Stores the registered file system device path value. This path does not | 65 // Stores the registered file system device path value. This path does not |
| 67 // correspond to a real device path (E.g.: "/usb:2,2:81282"). | 66 // correspond to a real device path (E.g.: "/usb:2,2:81282"). |
| 68 const std::string device_path_; | 67 const std::string device_path_; |
| 69 | 68 |
| 70 // Stores the device handle returned by | 69 // Stores the device handle returned by |
| 71 // MediaTransferProtocolManager::OpenStorage(). | 70 // MediaTransferProtocolManager::OpenStorage(). |
| 72 std::string device_handle_; | 71 std::string device_handle_; |
| 73 | 72 |
| 74 // Stores a reference to worker pool thread. All requests and response of file | 73 // Stores a reference to worker pool thread. All requests and response of file |
| 75 // operations are posted on |media_task_runner_|. | 74 // operations are posted on |media_task_runner_|. |
| 76 scoped_refptr<base::SequencedTaskRunner> media_task_runner_; | 75 scoped_refptr<base::SequencedTaskRunner> media_task_runner_; |
| 77 | 76 |
| 78 // |media_task_runner_| can wait on this event until the requested task is | 77 // |media_task_runner_| can wait on this event until the requested task is |
| 79 // complete. | 78 // complete. |
| 80 base::WaitableEvent on_task_completed_event_; | 79 base::WaitableEvent on_task_completed_event_; |
| 81 | 80 |
| 82 // Used to notify |media_task_runner_| pending tasks about the shutdown | 81 // Used to notify |media_task_runner_| pending tasks about the shutdown |
| 83 // sequence. Signaled on the UI thread. | 82 // sequence. Signaled on the UI thread. |
| 84 base::WaitableEvent on_shutdown_event_; | 83 base::WaitableEvent on_shutdown_event_; |
| 85 | 84 |
| 86 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux); | 85 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux); |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 } // namespace chrome | 88 } // namespace chrome |
| 90 | 89 |
| 91 #endif // CHROME_BROWSER_MEDIA_GALLERY_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ | 90 #endif // CHROME_BROWSER_MEDIA_GALLERY_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ |
| OLD | NEW |