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 #include "webkit/fileapi/media/mtp_device_interface_impl_linux.h" | |
6 | |
7 #include "base/sequenced_task_runner.h" | |
8 | |
9 namespace fileapi { | |
10 | |
11 MtpDeviceInterfaceImplLinux::MtpDeviceInterfaceImplLinux( | |
12 const FilePath::StringType& device_id, | |
13 base::SequencedTaskRunner* media_task_runner) | |
14 : device_id_(device_id), | |
15 media_task_runner_(media_task_runner) { | |
16 // Initialize the device in LazyInit() function. | |
17 // This object is constructed on IO thread. | |
18 } | |
19 | |
20 MtpDeviceInterfaceImplLinux::~MtpDeviceInterfaceImplLinux() { | |
21 // Do the clean up in DeleteOnCorrectThread() function. | |
22 // This object is destructed by media_task_runner. | |
kinuko
2012/07/30 23:19:03
nit: is destructed by -> must be destructed on ?
kmadhusu
2012/07/31 01:17:48
Done.
| |
23 } | |
24 | |
25 bool MtpDeviceInterfaceImplLinux::LazyInit() { | |
26 if (!media_task_runner_->RunsTasksOnCurrentThread()) | |
kinuko
2012/07/30 23:19:03
I think this must be DCHECK.
kmadhusu
2012/07/31 01:17:48
Done.
| |
27 return false; | |
28 | |
29 // TODO(kmadhusu, thestig): Open the device for communication. If is already | |
30 // opened, return. | |
31 return true; | |
32 } | |
33 | |
34 void MtpDeviceInterfaceImplLinux::DeleteOnCorrectThread() const { | |
35 media_task_runner_->DeleteSoon(FROM_HERE, this); | |
kinuko
2012/07/30 23:19:03
nit: If we're already on media_task_runner we don'
kmadhusu
2012/07/31 01:17:48
Done.
| |
36 } | |
37 | |
kinuko
2012/07/30 23:19:03
nit: please remove extra empty line
kmadhusu
2012/07/31 01:17:48
Done.
| |
38 | |
39 PlatformFileError MtpDeviceInterfaceImplLinux::GetFileInfo( | |
40 const FilePath& file_path, | |
41 PlatformFileInfo* file_info) { | |
42 if (!LazyInit()) | |
43 return base::PLATFORM_FILE_ERROR_SECURITY; | |
44 | |
45 NOTIMPLEMENTED(); | |
46 return base::PLATFORM_FILE_ERROR_SECURITY; | |
47 } | |
48 | |
49 FileSystemFileUtil::AbstractFileEnumerator* | |
50 MtpDeviceInterfaceImplLinux::CreateFileEnumerator( | |
51 const FilePath& root, | |
52 bool recursive) { | |
53 if (!LazyInit()) | |
54 return new FileSystemFileUtil::EmptyFileEnumerator(); | |
55 | |
56 NOTIMPLEMENTED(); | |
57 return new FileSystemFileUtil::EmptyFileEnumerator(); | |
58 } | |
59 | |
60 PlatformFileError MtpDeviceInterfaceImplLinux::Touch( | |
61 const FilePath& file_path, | |
62 const base::Time& last_access_time, | |
63 const base::Time& last_modified_time) { | |
64 if (!LazyInit()) | |
65 return base::PLATFORM_FILE_ERROR_SECURITY; | |
66 | |
67 NOTIMPLEMENTED(); | |
68 return base::PLATFORM_FILE_ERROR_SECURITY; | |
69 } | |
70 | |
71 bool MtpDeviceInterfaceImplLinux::PathExists(const FilePath& file_path) { | |
72 if (!LazyInit()) | |
73 return false; | |
74 | |
75 NOTIMPLEMENTED(); | |
76 return false; | |
77 } | |
78 | |
79 bool MtpDeviceInterfaceImplLinux::DirectoryExists(const FilePath& file_path) { | |
80 if (!LazyInit()) | |
81 return false; | |
82 | |
83 NOTIMPLEMENTED(); | |
84 return false; | |
85 } | |
86 | |
87 bool MtpDeviceInterfaceImplLinux::IsDirectoryEmpty(const FilePath& file_path) { | |
88 if (!LazyInit()) | |
89 return false; | |
90 | |
91 NOTIMPLEMENTED(); | |
92 return true; | |
93 } | |
94 | |
95 bool MtpDeviceInterfaceImplLinux::CreateSnapshotFile( | |
96 const FilePath& device_file_path, | |
97 const FilePath& local_path, | |
98 PlatformFileInfo* file_info) { | |
99 if (!LazyInit()) | |
100 return false; | |
101 | |
102 // Write the device_file_path data to local_path file and set the file_info | |
103 // accordingly. | |
104 | |
105 NOTIMPLEMENTED(); | |
106 return false; | |
107 } | |
108 | |
109 } // namespace fileapi | |
OLD | NEW |