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

Side by Side Diff: chrome/browser/system_monitor/portable_device_watcher_win.h

Issue 11573048: [Media Galleries] Move RemovableStorageInfo notifications to chrome namespace (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Working on windows Created 7 years, 10 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_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_
6 #define CHROME_BROWSER_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ 6 #define CHROME_BROWSER_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_
7 7
8 #include <portabledeviceapi.h> 8 #include <portabledeviceapi.h>
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/string16.h" 16 #include "base/string16.h"
17 #include "base/system_monitor/system_monitor.h" 17 #include "chrome/browser/system_monitor/removable_storage_notifications.h"
18 18
19 namespace base { 19 namespace base {
20 class SequencedTaskRunner; 20 class SequencedTaskRunner;
21 } 21 }
22 22
23 class FilePath; 23 class FilePath;
24 24
25 namespace chrome { 25 namespace chrome {
26 26
27 namespace test { 27 namespace test {
28 class TestPortableDeviceWatcherWin; 28 class TestPortableDeviceWatcherWin;
29 } 29 }
30 30
31 // This class watches the portable device mount points and sends notifications 31 // This class watches the portable device mount points and sends notifications
32 // to base::SystemMonitor about the attached/detached media transfer protocol 32 // about the attached/detached media transfer protocol (MTP) devices.
33 // (MTP) devices. This is a singleton class instantiated by 33 // This is a singleton class instantiated by
34 // RemovableDeviceNotificationsWindowWin. This class is created, destroyed and 34 // RemovableDeviceNotificationsWindowWin. This class is created, destroyed and
35 // operates on the UI thread, except for long running tasks it spins off to a 35 // operates on the UI thread, except for long running tasks it spins off to a
36 // SequencedTaskRunner. 36 // SequencedTaskRunner.
37 class PortableDeviceWatcherWin { 37 class PortableDeviceWatcherWin {
38 public: 38 public:
39 typedef std::vector<string16> StorageObjectIDs; 39 typedef std::vector<string16> StorageObjectIDs;
40 40
41 struct DeviceStorageObject { 41 struct DeviceStorageObject {
42 DeviceStorageObject(const string16& temporary_id, 42 DeviceStorageObject(const string16& temporary_id,
43 const std::string& persistent_id); 43 const std::string& persistent_id);
(...skipping 16 matching lines...) Expand all
60 string16 name; 60 string16 name;
61 61
62 // Device interface path. 62 // Device interface path.
63 string16 location; 63 string16 location;
64 64
65 // Device storage details. A device can have multiple data partitions. 65 // Device storage details. A device can have multiple data partitions.
66 StorageObjects storage_objects; 66 StorageObjects storage_objects;
67 }; 67 };
68 typedef std::vector<DeviceDetails> Devices; 68 typedef std::vector<DeviceDetails> Devices;
69 69
70 // TODO(gbillock): Change to take the device notifications object as
71 // an argument.
70 PortableDeviceWatcherWin(); 72 PortableDeviceWatcherWin();
71 virtual ~PortableDeviceWatcherWin(); 73 virtual ~PortableDeviceWatcherWin();
72 74
73 // Must be called after the browser blocking pool is ready for use. 75 // Must be called after the browser blocking pool is ready for use.
74 // RemovableDeviceNotificationsWindowsWin::Init() will call this function. 76 // RemovableDeviceNotificationsWindowsWin::Init() will call this function.
75 void Init(HWND hwnd); 77 void Init(HWND hwnd);
76 78
77 // Processes DEV_BROADCAST_DEVICEINTERFACE messages and triggers a 79 // Processes DEV_BROADCAST_DEVICEINTERFACE messages and triggers a
78 // SystemMonitor notification if appropriate. 80 // notification if appropriate.
79 void OnWindowMessage(UINT event_type, LPARAM data); 81 void OnWindowMessage(UINT event_type, LPARAM data);
80 82
81 // Gets the information of the MTP storage specified by |storage_device_id|. 83 // Gets the information of the MTP storage specified by |storage_device_id|.
82 // On success, returns true and fills in |device_location| with device 84 // On success, returns true and fills in |device_location| with device
83 // interface details and |storage_object_id| with storage object temporary 85 // interface details and |storage_object_id| with storage object temporary
84 // identifier. 86 // identifier.
85 virtual bool GetMTPStorageInfoFromDeviceId( 87 virtual bool GetMTPStorageInfoFromDeviceId(
86 const std::string& storage_device_id, 88 const std::string& storage_device_id,
87 string16* device_location, 89 string16* device_location,
88 string16* storage_object_id) const; 90 string16* storage_object_id) const;
89 91
90 private: 92 private:
91 friend class test::TestPortableDeviceWatcherWin; 93 friend class test::TestPortableDeviceWatcherWin;
92 94
93 // Key: MTP device storage unique id. 95 // Key: MTP device storage unique id.
94 // Value: Metadata for the given storage. 96 // Value: Metadata for the given storage.
95 typedef std::map<std::string, base::SystemMonitor::RemovableStorageInfo> 97 typedef std::map<std::string, RemovableStorageNotifications::StorageInfo>
96 MTPStorageMap; 98 MTPStorageMap;
97 99
98 // Key: MTP device plug and play ID string. 100 // Key: MTP device plug and play ID string.
99 // Value: Vector of device storage objects. 101 // Value: Vector of device storage objects.
100 typedef std::map<string16, StorageObjects> MTPDeviceMap; 102 typedef std::map<string16, StorageObjects> MTPDeviceMap;
101 103
102 // Helpers to enumerate existing MTP storage devices. 104 // Helpers to enumerate existing MTP storage devices.
103 virtual void EnumerateAttachedDevices(); 105 virtual void EnumerateAttachedDevices();
104 void OnDidEnumerateAttachedDevices(const Devices* devices, 106 void OnDidEnumerateAttachedDevices(const Devices* devices,
105 const bool result); 107 const bool result);
(...skipping 21 matching lines...) Expand all
127 129
128 // Used by |media_task_runner_| to create cancelable callbacks. 130 // Used by |media_task_runner_| to create cancelable callbacks.
129 base::WeakPtrFactory<PortableDeviceWatcherWin> weak_ptr_factory_; 131 base::WeakPtrFactory<PortableDeviceWatcherWin> weak_ptr_factory_;
130 132
131 DISALLOW_COPY_AND_ASSIGN(PortableDeviceWatcherWin); 133 DISALLOW_COPY_AND_ASSIGN(PortableDeviceWatcherWin);
132 }; 134 };
133 135
134 } // namespace chrome 136 } // namespace chrome
135 137
136 #endif // CHROME_BROWSER_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ 138 #endif // CHROME_BROWSER_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698