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

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

Issue 11088012: [Win, MediaGallery] Enumerate and handle mtp device attach/detach events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename storage_iter => storage_map_iter Created 8 years, 1 month 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_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_WIN_ H_ 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_WIN_ H_
6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_WIN_ H_ 6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_WIN_ H_
7 7
8 #include <windows.h>
9
10 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/system_monitor/system_monitor.h" 11 #include "base/system_monitor/system_monitor.h"
12 #include "chrome/browser/system_monitor/volume_mount_watcher_win.h"
13 12
14 class FilePath; 13 class FilePath;
15 14
16 namespace chrome { 15 namespace chrome {
17 16
17 class PortableDeviceWatcherWin;
18 class VolumeMountWatcherWin;
19
18 class RemovableDeviceNotificationsWindowWin; 20 class RemovableDeviceNotificationsWindowWin;
19 typedef RemovableDeviceNotificationsWindowWin RemovableDeviceNotifications; 21 typedef RemovableDeviceNotificationsWindowWin RemovableDeviceNotifications;
20 22
21 class RemovableDeviceNotificationsWindowWin { 23 class RemovableDeviceNotificationsWindowWin {
22 public: 24 public:
23 // Creates an instance of RemovableDeviceNotificationsWindowWin. Should only 25 // Creates an instance of RemovableDeviceNotificationsWindowWin. Should only
24 // be called by browser start up code. Use GetInstance() instead. 26 // be called by browser start up code. Use GetInstance() instead.
25 static RemovableDeviceNotificationsWindowWin* Create(); 27 static RemovableDeviceNotificationsWindowWin* Create();
26 28
27 virtual ~RemovableDeviceNotificationsWindowWin(); 29 virtual ~RemovableDeviceNotificationsWindowWin();
28 30
29 // base::SystemMonitor has a lifetime somewhat shorter than a Singleton and 31 // base::SystemMonitor has a lifetime somewhat shorter than a Singleton and
30 // |this| is constructed/destroyed just after/before SystemMonitor. 32 // |this| is constructed/destroyed just after/before SystemMonitor.
31 static RemovableDeviceNotificationsWindowWin* GetInstance(); 33 static RemovableDeviceNotificationsWindowWin* GetInstance();
32 34
33 // Must be called after the file thread is created. 35 // Must be called after the file thread is created.
34 void Init(); 36 void Init();
35 37
36 // Finds the device that contains |path| and populates |device_info|. 38 // Finds the device that contains |path| and populates |device_info|.
37 // Returns false if unable to find the device. 39 // Returns false if unable to find the device.
38 bool GetDeviceInfoForPath( 40 bool GetDeviceInfoForPath(
39 const FilePath& path, 41 const FilePath& path,
40 base::SystemMonitor::RemovableStorageInfo* device_info); 42 base::SystemMonitor::RemovableStorageInfo* device_info);
41 43
42 private: 44 private:
45 class PortableDeviceNotifications;
43 friend class TestRemovableDeviceNotificationsWindowWin; 46 friend class TestRemovableDeviceNotificationsWindowWin;
44 47
45 explicit RemovableDeviceNotificationsWindowWin( 48 // To support unit tests, this constructor takes |volume_mount_watcher| and
46 VolumeMountWatcherWin* volume_mount_watcher); 49 // |portable_device_watcher| objects. These params are either constructed in
50 // unit tests or in RemovableDeviceNotificationsWindowWin::Create() function.
51 RemovableDeviceNotificationsWindowWin(
52 VolumeMountWatcherWin* volume_mount_watcher,
53 PortableDeviceWatcherWin* portable_device_watcher);
47 54
48 // Gets the removable storage information given a |device_path|. On success, 55 // Gets the removable storage information given a |device_path|. On success,
49 // returns true and fills in |device_location|, |unique_id|, |name| and 56 // returns true and fills in |device_location|, |unique_id|, |name| and
50 // |removable|. 57 // |removable|.
51 bool GetDeviceInfo(const FilePath& device_path, 58 bool GetDeviceInfo(const FilePath& device_path,
52 string16* device_location, 59 string16* device_location,
53 std::string* unique_id, 60 std::string* unique_id,
54 string16* name, 61 string16* name,
55 bool* removable); 62 bool* removable);
56 63
57 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, 64 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam,
58 LPARAM lparam); 65 LPARAM lparam);
59 66
60 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, 67 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam,
61 LPARAM lparam); 68 LPARAM lparam);
62 69
63 void OnDeviceChange(UINT event_type, LPARAM data); 70 void OnDeviceChange(UINT event_type, LPARAM data);
64 71
65 // The window class of |window_|. 72 // The window class of |window_|.
66 ATOM window_class_; 73 ATOM window_class_;
67 74
68 // The handle of the module that contains the window procedure of |window_|. 75 // The handle of the module that contains the window procedure of |window_|.
69 HMODULE instance_; 76 HMODULE instance_;
70 HWND window_; 77 HWND window_;
71 78
72 // Store the volume mount point watcher to manage the mounted devices. 79 // The volume mount point watcher, used to manage the mounted devices.
73 scoped_refptr<VolumeMountWatcherWin> volume_mount_watcher_; 80 scoped_refptr<VolumeMountWatcherWin> volume_mount_watcher_;
74 81
82 // The portable device watcher, used to manage media transfer protocol
83 // devices.
84 scoped_ptr<PortableDeviceWatcherWin> portable_device_watcher_;
85
75 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsWindowWin); 86 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsWindowWin);
76 }; 87 };
77 88
78 } // namespace chrome 89 } // namespace chrome
79 90
80 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_W IN_H_ 91 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_W IN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698