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

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

Powered by Google App Engine
This is Rietveld 408576698