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"
17 class PortableDeviceWatcherWin;
18 class TestStorageMonitorWin;
19 class VolumeMountWatcherWin;
21 class StorageMonitorWin : public StorageMonitor {
23 // Should only be called by browser start up code.
24 // Use StorageMonitor::GetInstance() instead.
25 // To support unit tests, this constructor takes |volume_mount_watcher| and
26 // |portable_device_watcher| objects. These params are either constructed in
27 // unit tests or in StorageMonitorWin CreateInternal() function.
28 StorageMonitorWin(VolumeMountWatcherWin* volume_mount_watcher,
29 PortableDeviceWatcherWin* portable_device_watcher);
30 virtual ~StorageMonitorWin();
32 // Must be called after the file thread is created.
33 virtual void Init() OVERRIDE;
36 virtual bool GetStorageInfoForPath(const base::FilePath& path,
37 StorageInfo* device_info) const OVERRIDE;
38 virtual bool GetMTPStorageInfoFromDeviceId(
39 const std::string& storage_device_id,
40 base::string16* device_location,
41 base::string16* storage_object_id) const OVERRIDE;
43 virtual void EjectDevice(
44 const std::string& device_id,
45 base::Callback<void(EjectStatus)> callback) OVERRIDE;
48 class PortableDeviceNotifications;
49 friend class TestStorageMonitorWin;
51 // Gets the removable storage information given a |device_path|. On success,
52 // returns true and fills in |info|.
53 bool GetDeviceInfo(const base::FilePath& device_path,
54 StorageInfo* info) const;
56 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam,
59 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam,
62 void OnDeviceChange(UINT event_type, LPARAM data);
64 // The window class of |window_|.
67 // The handle of the module that contains the window procedure of |window_|.
71 // The volume mount point watcher, used to manage the mounted devices.
72 scoped_ptr<VolumeMountWatcherWin> volume_mount_watcher_;
74 // The portable device watcher, used to manage media transfer protocol
76 scoped_ptr<PortableDeviceWatcherWin> portable_device_watcher_;
78 DISALLOW_COPY_AND_ASSIGN(StorageMonitorWin);
81 #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_