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

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 comment and disabled MediaFileSystemRegistryTest.GalleryNameMTP Created 7 years, 11 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 CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_DELEGATE_IMPL_WIN_H_
6 #define CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_DELEGATE_IMPL_WIN_H_
7
8 #include <portabledeviceapi.h>
9 #include <string>
10
11 #include "base/platform_file.h"
12 #include "base/sequenced_task_runner_helpers.h"
13 #include "base/string16.h"
14 #include "base/synchronization/lock.h"
15 #include "base/win/scoped_comptr.h"
16 #include "chrome/browser/media_gallery/mtp_device_delegate_impl.h"
17 #include "webkit/fileapi/file_system_file_util.h"
18 #include "webkit/fileapi/media/mtp_device_delegate.h"
19
20 class FilePath;
21
22 namespace base {
23 class SequencedTaskRunner;
24 }
25
26 namespace chrome {
27
28 // MTPDeviceDelegateImplWin is used to communicate with the media transfer
29 // protocol (MTP) device to complete isolated file system operations. MTP
30 // device can have multiple data storage partitions. MTPDeviceDelegateImplWin
31 // is instantiated per MTP device storage partition using
32 // CreateMTPDeviceDelegate(). MTPDeviceDelegateImplWin lives on a sequenced
33 // task runner thread, except for CancelPendingTasksAndDeleteDelegate() which
34 // happens on the UI thread.
35 class MTPDeviceDelegateImplWin : public fileapi::MTPDeviceDelegate {
36 private:
37 friend void OnGotStorageInfoCreateDelegate(
38 const string16& device_location,
39 base::SequencedTaskRunner* media_task_runner,
40 const CreateMTPDeviceDelegateCallback& callback,
41 const string16& pnp_device_id,
42 const string16& storage_object_id);
43
44 friend class base::DeleteHelper<MTPDeviceDelegateImplWin>;
45
46 // Defer the device initializations until the first file operation request.
Lei Zhang 2013/01/14 23:25:30 nit: Defers
kmadhusu 2013/01/15 19:08:17 Done.
47 // Do all the initializations in LazyInit() function.
48 MTPDeviceDelegateImplWin(const string16& fs_root_path,
49 const string16& pnp_device_id,
50 const string16& storage_object_id,
51 base::SequencedTaskRunner* media_task_runner);
52
53 // Destructed via CancelPendingTasksAndDeleteDelegate().
54 virtual ~MTPDeviceDelegateImplWin();
55
56 // MTPDeviceDelegate:
57 virtual base::PlatformFileError GetFileInfo(
58 const FilePath& file_path,
59 base::PlatformFileInfo* file_info) OVERRIDE;
60 virtual scoped_ptr<fileapi::FileSystemFileUtil::AbstractFileEnumerator>
61 CreateFileEnumerator(const FilePath& root,
62 bool recursive) OVERRIDE;
63 virtual base::PlatformFileError CreateSnapshotFile(
64 const FilePath& device_file_path,
65 const FilePath& local_path,
66 base::PlatformFileInfo* file_info) OVERRIDE;
67 virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE;
68
69 // Returns whether the device is ready for communication.
70 bool LazyInit();
71
72 // Returns the object id of the file object specified by the |file_path|,
73 // e.g. if the |file_path| is "\\MTP:StorageSerial:SID-{1001,,192}:125\DCIM"
74 // and |registered_device_path_| is "\\MTP:StorageSerial:SID-{1001,,192}:125",
75 // this function returns the identifier of the "DCIM" folder object.
76 //
77 // Returns an empty string if the device is detached while the request is in
78 // progress.
79 string16 GetFileObjectIdFromPath(const string16& file_path);
80
81 // The Pnp Device Id, used to open the device for communication,
Lei Zhang 2013/01/14 23:25:30 nit: plug & play abbreviates to PnP.
kmadhusu 2013/01/15 19:08:17 Done.
82 // e.g. "\\?\usb#vid_04a9&pid_3073#12#{6ac27878-a6fa-4155-ba85-f1d4f33}".
83 const string16 pnp_device_id_;
84
85 // The media file system root path, which is obtained during the registration
86 // of MTP device storage partition as a file system,
87 // e.g. "\\MTP:StorageSerial:SID-{10001,E,9823}:237483".
88 const string16 registered_device_path_;
89
90 // The MTP device storage partition object identifier, used to enumerate the
91 // storage contents, e.g. "s10001".
92 const string16 storage_object_id_;
93
94 // The task runner where most of the class lives and runs (save for
95 // CancelPendingTasksAndDeleteDelegate).
96 scoped_refptr<base::SequencedTaskRunner> media_task_runner_;
97
98 // The portable device.
99 base::win::ScopedComPtr<IPortableDevice> device_;
100
101 // The lock to protect |cancel_pending_tasks_|. |cancel_pending_tasks_| is
102 // set on the UI thread when the
103 // (1) Browser application is in shutdown mode (or)
104 // (2) Last extension using this MTP device is destroyed (or)
105 // (3) Attached MTP device is removed (or)
106 // (4) User revoked the MTP device gallery permission.
107 base::Lock cancel_tasks_lock_;
108 bool cancel_pending_tasks_;
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