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

Side by Side Diff: chrome/browser/media_gallery/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: diff against codereview.chromium.org/11088012 Created 8 years, 2 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ 5 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_WIN_H_
6 #define CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ 6 #define CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_WIN_H_
7
8 #include <PortableDeviceApi.h>
7 9
8 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
9 #include "base/platform_file.h" 11 #include "base/platform_file.h"
12 #include "base/string16.h"
10 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "base/win/scoped_comptr.h"
11 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.h"
13 #include "webkit/fileapi/file_system_file_util.h" 17 #include "webkit/fileapi/file_system_file_util.h"
14 #include "webkit/fileapi/media/mtp_device_delegate.h" 18 #include "webkit/fileapi/media/mtp_device_delegate.h"
15 19
16 class FilePath; 20 class FilePath;
17 21
18 namespace base { 22 namespace base {
19 class SequencedTaskRunner; 23 class SequencedTaskRunner;
20 } 24 }
21 25
22 namespace chrome { 26 namespace chrome {
23 27
24 // Helper class to communicate with MTP storage to complete isolated file system 28 // Helper class to communicate with MTP storage to complete isolated file system
25 // operations. This class contains platform specific code to communicate with 29 // operations. This class contains platform specific code to communicate with
26 // the attached MTP storage. Instantiate this class per MTP storage. 30 // the attached MTP storage. Instantiate this class per MTP storage.
27 // This class is ref-counted, because MtpDeviceDelegate is ref-counted. 31 // This class is ref-counted, because MtpDeviceDelegate is ref-counted.
28 class MtpDeviceDelegateImplLinux : public fileapi::MtpDeviceDelegate, 32 class MtpDeviceDelegateImplWin : public fileapi::MtpDeviceDelegate,
29 public content::NotificationObserver { 33 public content::NotificationObserver {
30 public: 34 public:
31 // Constructed on UI thread. Defer the device initializations until the first 35 // Constructed on UI thread. Defer the device initializations until the first
32 // file operation request. Do all the initializations in LazyInit() function. 36 // file operation request. Do all the initializations in LazyInit() function.
33 explicit MtpDeviceDelegateImplLinux(const std::string& device_location); 37 explicit MtpDeviceDelegateImplWin(const string16& pnp_device_id);
34 38
35 // Overridden from MtpDeviceDelegate. All the functions are called on 39 // Overridden from MtpDeviceDelegate. All the functions are called on
36 // |media_task_runner_|. 40 // |media_task_runner_|.
37 virtual base::PlatformFileError GetFileInfo( 41 virtual base::PlatformFileError GetFileInfo(
38 const FilePath& file_path, 42 const FilePath& file_path,
39 base::PlatformFileInfo* file_info) OVERRIDE; 43 base::PlatformFileInfo* file_info) OVERRIDE;
40 virtual fileapi::FileSystemFileUtil::AbstractFileEnumerator* 44 virtual fileapi::FileSystemFileUtil::AbstractFileEnumerator*
41 CreateFileEnumerator(const FilePath& root, bool recursive) OVERRIDE; 45 CreateFileEnumerator(const FilePath& root, bool recursive) OVERRIDE;
42 virtual base::PlatformFileError CreateSnapshotFile( 46 virtual base::PlatformFileError CreateSnapshotFile(
43 const FilePath& device_file_path, 47 const FilePath& device_file_path,
44 const FilePath& local_path, 48 const FilePath& local_path,
45 base::PlatformFileInfo* file_info) OVERRIDE; 49 base::PlatformFileInfo* file_info) OVERRIDE;
46 virtual base::SequencedTaskRunner* media_task_runner() OVERRIDE; 50 virtual base::SequencedTaskRunner* media_task_runner() OVERRIDE;
47 virtual void DeleteOnCorrectThread() const OVERRIDE; 51 virtual void DeleteOnCorrectThread() const OVERRIDE;
48 52
49 private: 53 private:
50 friend struct fileapi::MtpDeviceDelegateDeleter; 54 friend struct fileapi::MtpDeviceDelegateDeleter;
51 friend class base::DeleteHelper<MtpDeviceDelegateImplLinux>; 55 friend class base::DeleteHelper<MtpDeviceDelegateImplWin>;
52 56
53 // Private because this class is ref-counted. 57 // Private because this class is ref-counted.
54 virtual ~MtpDeviceDelegateImplLinux(); 58 virtual ~MtpDeviceDelegateImplWin();
55 59
56 // content::NotificationObserver implementation. 60 // content::NotificationObserver implementation.
57 virtual void Observe(int type, 61 virtual void Observe(int type,
58 const content::NotificationSource& source, 62 const content::NotificationSource& source,
59 const content::NotificationDetails& details) OVERRIDE; 63 const content::NotificationDetails& details) OVERRIDE;
60 64
61 // Opens the device for communication. This function is called on 65 // Opens the device for communication. This function is called on
62 // |media_task_runner_|. Returns true if the device is ready for 66 // |media_task_runner_|. Returns true if the device is ready for
63 // communication, else false. 67 // communication, else false.
64 bool LazyInit(); 68 bool LazyInit();
65 69
66 // Stores the registered file system device path value. This path does not 70 // Stores the plug and play device ID string. This is used to open the device
Peter Kasting 2012/10/24 22:51:41 Nit: Member variables should not say "stores a" or
kmadhusu 2012/10/25 19:12:48 Done.
67 // correspond to a real device path (E.g.: "/usb:2,2:81282"). 71 // for communication.
68 const std::string device_path_; 72 // (E.g.:\\?\usb#vid_04a9&pid_3073#12#{6ac27878-a6fa-4155-ba85-f98f491d4f33})
Peter Kasting 2012/10/24 22:51:41 Nit: For clarity, remove the parens, add quotes, a
kmadhusu 2012/10/25 19:12:48 Done.
73 string16 pnp_device_id_;
69 74
70 // Stores the device handle returned by 75 // Stores the registered media file system path.
71 // MediaTransferProtocolManager::OpenStorage(). 76 // E.g.: \\mtp:StorageSerial:SID-{10001,E,9823}:237483
72 std::string device_handle_; 77 const string16 registered_dev_path_;
Peter Kasting 2012/10/24 22:51:41 Nit: Do not abbreviate "device" to "dev"
kmadhusu 2012/10/25 19:12:48 Done.
78
79 // Stores the removable storage root object identifier.
80 string16 storage_object_id_;
73 81
74 // Stores a reference to worker pool thread. All requests and response of file 82 // Stores a reference to worker pool thread. All requests and response of file
75 // operations are posted on |media_task_runner_|. 83 // operations are posted on |media_task_runner_|.
76 scoped_refptr<base::SequencedTaskRunner> media_task_runner_; 84 scoped_refptr<base::SequencedTaskRunner> media_task_runner_;
77 85
78 // |media_task_runner_| can wait on this event until the requested task is 86 // Stores a pointer to IPortableDevice interface that provides access to a
79 // complete. 87 // portable device.
Peter Kasting 2012/10/24 22:51:41 Nit: This comment mostly restates the code. If th
kmadhusu 2012/10/25 19:12:48 Done.
80 base::WaitableEvent on_task_completed_event_; 88 base::win::ScopedComPtr<IPortableDevice> device_;
81 89
82 // Used to notify |media_task_runner_| pending tasks about the shutdown 90 // Used to notify |media_task_runner_| pending tasks about the shutdown
83 // sequence. 91 // sequence.
84 base::WaitableEvent on_shutdown_event_; 92 base::WaitableEvent on_shutdown_event_;
85 93
86 // Handles registering notifications with the NotificationService. 94 // Handles registering notifications with the NotificationService.
87 // Used to listen for application termination message. 95 // Used to listen for application termination message.
88 content::NotificationRegistrar registrar_; 96 content::NotificationRegistrar registrar_;
89 97
90 DISALLOW_COPY_AND_ASSIGN(MtpDeviceDelegateImplLinux); 98 DISALLOW_COPY_AND_ASSIGN(MtpDeviceDelegateImplWin);
91 }; 99 };
92 100
93 } // namespace chrome 101 } // namespace chrome
94 102
95 #endif // CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ 103 #endif // CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_WIN_H_
OLDNEW
« no previous file with comments | « chrome/browser/media_gallery/mtp_device_delegate_impl.h ('k') | chrome/browser/media_gallery/mtp_device_delegate_impl_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698