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

Side by Side Diff: chrome/browser/media_gallery/win/mtp_device_delegate_impl_win.h

Issue 11297002: [Media Gallery] Added code to support mtp device media file system on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments Created 8 years, 1 month 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 // This class supports media transfer protocol (MTP) device file system
6 // operations. This class communicates with the portable device and completes
7 // the requested file system operation. MTPDeviceMapService owns this object.
8 // This object is constructed and destructed on UI thread. All the device
9 // operations are performed on the blocking thread. A portable device can have
10 // multiple data partitions. A user can register each partition as a media
11 // file system. This class is instantitated per MTP device storage.
12
13 #ifndef CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_DELEGATE_IMPL_WIN_H_
14 #define CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_DELEGATE_IMPL_WIN_H_
15
16 #include <portabledeviceapi.h>
17
18 #include "base/memory/ref_counted.h"
19 #include "base/platform_file.h"
20 #include "base/string16.h"
21 #include "base/synchronization/cancellation_flag.h"
22 #include "base/win/scoped_comptr.h"
23 #include "content/public/browser/notification_observer.h"
24 #include "content/public/browser/notification_registrar.h"
25 #include "webkit/fileapi/file_system_file_util.h"
26 #include "webkit/fileapi/media/mtp_device_delegate.h"
27
28 class FilePath;
29
30 namespace base {
31 class SequencedTaskRunner;
32 }
33
34 namespace chrome {
35
36 // Helper class to communicate with MTP storage to complete isolated file system
37 // operations. This class contains platform specific code to communicate with
38 // the attached MTP storage. Instantiate this class per MTP storage.
39 // This class is ref-counted, because MtpDeviceDelegate is ref-counted.
Peter Kasting 2012/11/01 21:38:37 And does MtpDeviceDelegate really need to be ref-c
kmadhusu 2012/11/02 03:27:16 Yes. This class is instantiated per MTP device sto
Peter Kasting 2012/11/02 04:08:11 Please point me to somewhere that details the owne
kmadhusu 2012/11/29 23:58:14 MTPDeviceDelegateImplWin is no longer ref-counted.
40 class MTPDeviceDelegateImplWin : public fileapi::MtpDeviceDelegate,
41 public content::NotificationObserver {
42 public:
43 // Constructed on UI thread. Defer the device initializations until the first
44 // file operation request. Do all the initializations in LazyInit() function.
45 explicit MTPDeviceDelegateImplWin(const string16& pnp_device_id);
46
47 // MtpDeviceDelegate:
48 virtual base::PlatformFileError GetFileInfo(
49 const FilePath& file_path,
50 base::PlatformFileInfo* file_info) OVERRIDE;
51 virtual fileapi::FileSystemFileUtil::AbstractFileEnumerator*
Peter Kasting 2012/11/01 21:38:37 Nit: It would be nice for this function to return
kmadhusu 2012/11/02 03:27:16 Will fix it in a separate CL. (This function signa
kmadhusu 2012/11/29 23:58:14 Fixed.
52 CreateFileEnumerator(const FilePath& root, bool recursive) OVERRIDE;
53 virtual base::PlatformFileError CreateSnapshotFile(
54 const FilePath& device_file_path,
55 const FilePath& local_path,
56 base::PlatformFileInfo* file_info) OVERRIDE;
57 virtual base::SequencedTaskRunner* media_task_runner() OVERRIDE;
Peter Kasting 2012/11/01 21:38:37 Nit: virtual functions should never be named unix_
kmadhusu 2012/11/02 03:27:16 Will fix in a separate CL. I have to change severa
kmadhusu 2012/11/29 23:58:14 Fixed.
58 virtual void DeleteOnCorrectThread() const OVERRIDE;
59
60 private:
61 friend struct fileapi::MtpDeviceDelegateDeleter;
62 friend class base::DeleteHelper<MTPDeviceDelegateImplWin>;
63
64 // Private because this class is ref-counted.
65 virtual ~MTPDeviceDelegateImplWin();
66
67 // content::NotificationObserver:
68 virtual void Observe(int type,
69 const content::NotificationSource& source,
70 const content::NotificationDetails& details) OVERRIDE;
71
72 // Opens the device for communication. This function is called on the
73 // sequenced task runner. Returns true if the device is ready for
74 // communication, else false.
75 bool LazyInit();
76
77 // Returns the object id of the file object specified by the |file_path|,
78 // e.g. If the |file_path| is "\\MTP:StorageSerial:SID-{1001,,192}:125\DCIM"
Peter Kasting 2012/11/01 21:38:37 Nit: If -> if
kmadhusu 2012/11/02 03:27:16 Done.
79 // and |registered_device_path_| is "\\MTP:StorageSerial:SID-{1001,,192}:125",
80 // this function returns the object id of "DCIM" folder.
81 string16 GetFileObjectIdFromPath(const string16& file_path);
82
83 // The Pnp Device Id, used to open the device for communication,
84 // e.g. "\\?\usb#vid_04a9&pid_3073#12#{6ac27878-a6fa-4155-ba85-f1d4f33}".
85 string16 pnp_device_id_;
86
87 // The media file system root path, which is obtained during the registration
88 // of MTP device storage as a file system,
89 // e.g. "\\MTP:StorageSerial:SID-{10001,E,9823}:237483".
90 const string16 registered_device_path_;
91
92 // The MTP device storage object identifier, used to enumerate the storage
93 // contents, e.g. "s10001".
94 string16 storage_object_id_;
95
96 // The task runner used to execute tasks that may take a long time and thus
97 // should not be performed on the UI thread.
98 scoped_refptr<base::SequencedTaskRunner> media_task_runner_;
99
100 // The portable device.
101 base::win::ScopedComPtr<IPortableDevice> device_;
102
103 // Used to listen for NOTIFICATION_APP_TERMINATING message.
Peter Kasting 2012/11/01 21:38:37 As in your previous change, you should not listen
kmadhusu 2012/11/02 03:27:16 As I said earlier, this is a shared object. I cann
Peter Kasting 2012/11/02 04:08:11 Again, I'm not convinced, especially after we move
kmadhusu 2012/11/29 23:58:14 Fixed. Code no longer listens to app termination m
104 content::NotificationRegistrar registrar_;
105
106 // Used to notify the blocking tasks about the application termination
107 // message.
108 base::CancellationFlag app_terminating_flag_;
109
110 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplWin);
111 };
112
113 } // namespace chrome
114
115 #endif // CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_DELEGATE_IMPL_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698