Removing WTL from content runner.
[chromium-blink-merge.git] / components / storage_monitor / storage_monitor_win.h
blob65681b4dbf514d0f1850fdcac0f1ba1d56c65f33
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_
6 #define COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "components/storage_monitor/storage_monitor.h"
13 namespace base {
14 class FilePath;
17 namespace storage_monitor {
19 class PortableDeviceWatcherWin;
20 class TestStorageMonitorWin;
21 class VolumeMountWatcherWin;
23 class StorageMonitorWin : public StorageMonitor {
24 public:
25 // Should only be called by browser start up code.
26 // Use StorageMonitor::GetInstance() instead.
27 // To support unit tests, this constructor takes |volume_mount_watcher| and
28 // |portable_device_watcher| objects. These params are either constructed in
29 // unit tests or in StorageMonitorWin CreateInternal() function.
30 StorageMonitorWin(VolumeMountWatcherWin* volume_mount_watcher,
31 PortableDeviceWatcherWin* portable_device_watcher);
32 virtual ~StorageMonitorWin();
34 // Must be called after the file thread is created.
35 virtual void Init() OVERRIDE;
37 // StorageMonitor:
38 virtual bool GetStorageInfoForPath(const base::FilePath& path,
39 StorageInfo* device_info) const OVERRIDE;
40 virtual bool GetMTPStorageInfoFromDeviceId(
41 const std::string& storage_device_id,
42 base::string16* device_location,
43 base::string16* storage_object_id) const OVERRIDE;
45 virtual void EjectDevice(
46 const std::string& device_id,
47 base::Callback<void(EjectStatus)> callback) OVERRIDE;
49 private:
50 class PortableDeviceNotifications;
51 friend class TestStorageMonitorWin;
53 void MediaChangeNotificationRegister();
55 // Gets the removable storage information given a |device_path|. On success,
56 // returns true and fills in |info|.
57 bool GetDeviceInfo(const base::FilePath& device_path,
58 StorageInfo* info) const;
60 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam,
61 LPARAM lparam);
63 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam,
64 LPARAM lparam);
66 void OnDeviceChange(UINT event_type, LPARAM data);
67 void OnMediaChange(WPARAM wparam, LPARAM lparam);
69 // The window class of |window_|.
70 ATOM window_class_;
72 // The handle of the module that contains the window procedure of |window_|.
73 HMODULE instance_;
74 HWND window_;
76 // The handle of a registration for shell notifications.
77 ULONG shell_change_notify_id_;
79 // The volume mount point watcher, used to manage the mounted devices.
80 scoped_ptr<VolumeMountWatcherWin> volume_mount_watcher_;
82 // The portable device watcher, used to manage media transfer protocol
83 // devices.
84 scoped_ptr<PortableDeviceWatcherWin> portable_device_watcher_;
86 DISALLOW_COPY_AND_ASSIGN(StorageMonitorWin);
89 } // namespace storage_monitor
91 #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_