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

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

Powered by Google App Engine
This is Rietveld 408576698