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

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: Make singleton pointer live in base class. 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
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 // This class watches the portable device mount points and sends notifications 27 // This class watches the portable device mount points and sends notifications
28 // to base::SystemMonitor about the attached/detached media transfer protocol 28 // about the attached/detached media transfer protocol (MTP) devices.
29 // (MTP) devices. This is a singleton class instantiated by 29 // This is a singleton class instantiated by
30 // RemovableDeviceNotificationsWindowWin. This class is created, destroyed and 30 // RemovableDeviceNotificationsWindowWin. This class is created, destroyed and
31 // operates on the UI thread, except for long running tasks it spins off to a 31 // operates on the UI thread, except for long running tasks it spins off to a
32 // SequencedTaskRunner. 32 // SequencedTaskRunner.
33 class PortableDeviceWatcherWin { 33 class PortableDeviceWatcherWin {
34 public: 34 public:
35 typedef std::vector<string16> StorageObjectIDs; 35 typedef std::vector<string16> StorageObjectIDs;
36 36
37 struct DeviceStorageObject { 37 struct DeviceStorageObject {
38 DeviceStorageObject(const string16& temporary_id, 38 DeviceStorageObject(const string16& temporary_id,
39 const std::string& persistent_id); 39 const std::string& persistent_id);
(...skipping 13 matching lines...) Expand all
53 string16 name; 53 string16 name;
54 54
55 // Device interface path. 55 // Device interface path.
56 string16 location; 56 string16 location;
57 57
58 // Device storage details. A device can have multiple data partitions. 58 // Device storage details. A device can have multiple data partitions.
59 StorageObjects storage_objects; 59 StorageObjects storage_objects;
60 }; 60 };
61 typedef std::vector<DeviceDetails> Devices; 61 typedef std::vector<DeviceDetails> Devices;
62 62
63 // !!! change to take the device notifs as arg
vandebo (ex-Chrome) 2013/01/18 18:42:58 nit: TODO
Greg Billock 2013/01/22 20:00:39 Done. On 2013/01/18 18:42:58, vandebo wrote:
63 PortableDeviceWatcherWin(); 64 PortableDeviceWatcherWin();
64 virtual ~PortableDeviceWatcherWin(); 65 virtual ~PortableDeviceWatcherWin();
65 66
66 // Must be called after the browser blocking pool is ready for use. 67 // Must be called after the browser blocking pool is ready for use.
67 // RemovableDeviceNotificationsWindowsWin::Init() will call this function. 68 // RemovableDeviceNotificationsWindowsWin::Init() will call this function.
68 void Init(HWND hwnd); 69 void Init(HWND hwnd);
69 70
70 // Processes DEV_BROADCAST_DEVICEINTERFACE messages and triggers a 71 // Processes DEV_BROADCAST_DEVICEINTERFACE messages and triggers a
71 // SystemMonitor notification if appropriate. 72 // notification if appropriate.
72 void OnWindowMessage(UINT event_type, LPARAM data); 73 void OnWindowMessage(UINT event_type, LPARAM data);
73 74
74 private: 75 private:
75 friend class TestPortableDeviceWatcherWin; 76 friend class TestPortableDeviceWatcherWin;
76 77
77 // Key: MTP device storage unique id. 78 // Key: MTP device storage unique id.
78 // Value: Metadata for the given storage. 79 // Value: Metadata for the given storage.
79 typedef std::map<std::string, base::SystemMonitor::RemovableStorageInfo> 80 typedef std::map<std::string, RemovableStorageNotifications::StorageInfo>
80 MTPStorageMap; 81 MTPStorageMap;
81 82
82 // Key: MTP device plug and play ID string. 83 // Key: MTP device plug and play ID string.
83 // Value: Vector of device storage objects. 84 // Value: Vector of device storage objects.
84 typedef std::map<string16, StorageObjects> MTPDeviceMap; 85 typedef std::map<string16, StorageObjects> MTPDeviceMap;
85 86
86 // Helpers to enumerate existing MTP storage devices. 87 // Helpers to enumerate existing MTP storage devices.
87 virtual void EnumerateAttachedDevices(); 88 virtual void EnumerateAttachedDevices();
88 virtual void OnDidEnumerateAttachedDevices(const Devices* devices, 89 virtual void OnDidEnumerateAttachedDevices(const Devices* devices,
89 const bool result); 90 const bool result);
(...skipping 21 matching lines...) Expand all
111 112
112 // Used by |media_task_runner_| to create cancelable callbacks. 113 // Used by |media_task_runner_| to create cancelable callbacks.
113 base::WeakPtrFactory<PortableDeviceWatcherWin> weak_ptr_factory_; 114 base::WeakPtrFactory<PortableDeviceWatcherWin> weak_ptr_factory_;
114 115
115 DISALLOW_COPY_AND_ASSIGN(PortableDeviceWatcherWin); 116 DISALLOW_COPY_AND_ASSIGN(PortableDeviceWatcherWin);
116 }; 117 };
117 118
118 } // namespace chrome 119 } // namespace chrome
119 120
120 #endif // CHROME_BROWSER_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ 121 #endif // CHROME_BROWSER_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698