Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: webkit/fileapi/media/mtp_device_interface_impl_linux.h

Issue 10781014: Isolated FS for media devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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"
11 #include "base/sequenced_task_runner_helpers.h"
12 #include "base/timer.h"
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;
19 class Time;
20 }
21
22 namespace fileapi {
23
24 using base::PlatformFileError;
25 using base::PlatformFileInfo;
26 using base::RefCountedThreadSafe;
27 using base::Time;
28 using base::SequencedTaskRunner;
kinuko 2012/07/31 05:35:44 nit: Some other fileapi header file does the same
kmadhusu 2012/07/31 19:47:24 sure. Done.
29
30 struct DefaultMtpDeviceInterfaceImplDeleter;
31
32 // Helper class to support MTP device isolated file system operations. This
33 // class contains platform specific code to communicate with the attached
34 // MTP device. We instantiate this class per MTP device. MTP device is
35 // opened for communication during initialization and closed during
36 // destruction.
37 class MtpDeviceInterfaceImplLinux :
38 public MediaDeviceInterface,
39 public RefCountedThreadSafe<MtpDeviceInterfaceImplLinux,
40 DefaultMtpDeviceInterfaceImplDeleter> {
41 public:
42 MtpDeviceInterfaceImplLinux(const FilePath::StringType& device_id,
43 SequencedTaskRunner* media_task_runner) OVERRIDE;
44
45 // MediaDeviceInterface methods.
46 virtual PlatformFileError GetFileInfo(const FilePath& file_path,
47 PlatformFileInfo* file_info) OVERRIDE;
48
49 virtual FileSystemFileUtil::AbstractFileEnumerator* CreateFileEnumerator(
50 const FilePath& root,
51 bool recursive) OVERRIDE;
52
53 virtual PlatformFileError Touch(const FilePath& file_path,
54 const Time& last_access_time,
55 const Time& last_modified_time) OVERRIDE;
56
57 virtual bool PathExists(const FilePath& file_path) OVERRIDE;
58 virtual bool DirectoryExists(const FilePath& file_path) OVERRIDE;
59 virtual bool IsDirectoryEmpty(const FilePath& file_path) OVERRIDE;
60 virtual PlatformFileError CreateSnapshotFile(
61 const FilePath& device_file_path,
62 const FilePath& local_path,
63 PlatformFileInfo* file_info) OVERRIDE;
64
65 private:
66 friend struct DefaultMtpDeviceInterfaceImplDeleter;
67 friend class base::DeleteHelper<MtpDeviceInterfaceImplLinux>;
68 friend class RefCountedThreadSafe<MtpDeviceInterfaceImplLinux,
69 DefaultMtpDeviceInterfaceImplDeleter>;
70
71 virtual ~MtpDeviceInterfaceImplLinux();
72 void DeleteOnCorrectThread() const;
73
74 // Device initialization should be done in |media_task_runner_|.
75 bool LazyInit();
76
77 // Mtp device id.
78 FilePath::StringType device_id_;
79 scoped_refptr<SequencedTaskRunner> media_task_runner_;
80
81 DISALLOW_COPY_AND_ASSIGN(MtpDeviceInterfaceImplLinux);
82 };
83
84 struct DefaultMtpDeviceInterfaceImplDeleter {
85 static void Destruct(const MtpDeviceInterfaceImplLinux* device_impl) {
86 device_impl->DeleteOnCorrectThread();
87 }
88 };
89
90 } // namespace fileapi
91
92 #endif // WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_INTERFACE_IMPL_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698