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 namespace storage_monitor
{
19 class PortableDeviceWatcherWin
;
20 class TestStorageMonitorWin
;
21 class VolumeMountWatcherWin
;
23 class StorageMonitorWin
: public StorageMonitor
{
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
;
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
;
50 class PortableDeviceNotifications
;
51 friend class TestStorageMonitorWin
;
53 // Gets the removable storage information given a |device_path|. On success,
54 // returns true and fills in |info|.
55 bool GetDeviceInfo(const base::FilePath
& device_path
,
56 StorageInfo
* info
) const;
58 static LRESULT CALLBACK
WndProcThunk(HWND hwnd
, UINT message
, WPARAM wparam
,
61 LRESULT CALLBACK
WndProc(HWND hwnd
, UINT message
, WPARAM wparam
,
64 void OnDeviceChange(UINT event_type
, LPARAM data
);
66 // The window class of |window_|.
69 // The handle of the module that contains the window procedure of |window_|.
73 // The volume mount point watcher, used to manage the mounted devices.
74 scoped_ptr
<VolumeMountWatcherWin
> volume_mount_watcher_
;
76 // The portable device watcher, used to manage media transfer protocol
78 scoped_ptr
<PortableDeviceWatcherWin
> portable_device_watcher_
;
80 DISALLOW_COPY_AND_ASSIGN(StorageMonitorWin
);
83 } // namespace storage_monitor
85 #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_