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_MTP_DEVICE_INTERFACE_IMPL_LINUX_H_ | |
6 #define WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_INTERFACE_IMPL_LINUX_H_ | |
7 | |
8 #include "base/file_path.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/platform_file.h" | |
Lei Zhang
2012/08/01 03:06:30
nit: probably not needed.
kmadhusu
2012/08/01 23:39:35
Done.
| |
11 #include "base/sequenced_task_runner_helpers.h" | |
12 #include "base/timer.h" | |
Lei Zhang
2012/08/01 03:06:30
nit: not needed
kmadhusu
2012/08/01 23:39:35
Done.
| |
13 #include "webkit/fileapi/file_system_file_util.h" | |
14 #include "webkit/fileapi/media/media_device_interface.h" | |
15 | |
16 namespace base { | |
17 struct PlatformFileInfo; | |
18 class SequencedTaskRunner; | |
Lei Zhang
2012/08/01 03:06:30
nit: not needed since you already have the header
kmadhusu
2012/08/01 23:39:35
I did not include the header. So this declaration
| |
19 class Time; | |
20 } | |
21 | |
22 namespace fileapi { | |
23 | |
24 struct DefaultMtpDeviceInterfaceImplDeleter; | |
25 | |
26 // Helper class to support MTP device isolated file system operations. This | |
27 // class contains platform specific code to communicate with the attached | |
28 // MTP device. We instantiate this class per MTP device. MTP device is | |
29 // opened for communication during initialization and closed during | |
30 // destruction. | |
31 class MtpDeviceInterfaceImplLinux | |
32 : public MediaDeviceInterface, | |
33 public base::RefCountedThreadSafe<MtpDeviceInterfaceImplLinux, | |
34 DefaultMtpDeviceInterfaceImplDeleter> { | |
35 public: | |
36 MtpDeviceInterfaceImplLinux( | |
37 const FilePath::StringType& device_id, | |
38 base::SequencedTaskRunner* media_task_runner); | |
39 | |
40 // MediaDeviceInterface methods. | |
41 virtual base::PlatformFileError GetFileInfo( | |
42 const FilePath& file_path, | |
43 base::PlatformFileInfo* file_info) OVERRIDE; | |
44 virtual FileSystemFileUtil::AbstractFileEnumerator* CreateFileEnumerator( | |
45 const FilePath& root, | |
46 bool recursive) OVERRIDE; | |
47 virtual base::PlatformFileError Touch( | |
48 const FilePath& file_path, | |
49 const base::Time& last_access_time, | |
50 const base::Time& last_modified_time) OVERRIDE; | |
51 virtual bool PathExists(const FilePath& file_path) OVERRIDE; | |
52 virtual bool DirectoryExists(const FilePath& file_path) OVERRIDE; | |
53 virtual bool IsDirectoryEmpty(const FilePath& file_path) OVERRIDE; | |
54 virtual base::PlatformFileError CreateSnapshotFile( | |
55 const FilePath& device_file_path, | |
56 const FilePath& local_path, | |
57 base::PlatformFileInfo* file_info) OVERRIDE; | |
58 | |
59 private: | |
60 friend struct DefaultMtpDeviceInterfaceImplDeleter; | |
61 friend class base::DeleteHelper<MtpDeviceInterfaceImplLinux>; | |
62 friend class base::RefCountedThreadSafe<MtpDeviceInterfaceImplLinux, | |
63 DefaultMtpDeviceInterfaceImplDeleter>; | |
64 | |
65 virtual ~MtpDeviceInterfaceImplLinux(); | |
66 void DeleteOnCorrectThread() const; | |
67 | |
68 // Device initialization should be done in |media_task_runner_|. | |
69 bool LazyInit(); | |
70 | |
71 // Mtp device id. | |
72 FilePath::StringType device_id_; | |
73 scoped_refptr<base::SequencedTaskRunner> media_task_runner_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(MtpDeviceInterfaceImplLinux); | |
76 }; | |
77 | |
78 struct DefaultMtpDeviceInterfaceImplDeleter { | |
79 static void Destruct(const MtpDeviceInterfaceImplLinux* device_impl) { | |
80 device_impl->DeleteOnCorrectThread(); | |
81 } | |
82 }; | |
83 | |
84 } // namespace fileapi | |
85 | |
86 #endif // WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_INTERFACE_IMPL_LINUX_H_ | |
OLD | NEW |