Ensure low-memory renderers retry failed loads correctly.
[chromium-blink-merge.git] / components / storage_monitor / storage_monitor_win.h
blob2a99f12570b3e8f74d413af01db7754c6e824118
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 ~StorageMonitorWin() override;
34 // Must be called after the file thread is created.
35 void Init() override;
37 // StorageMonitor:
38 bool GetStorageInfoForPath(const base::FilePath& path,
39 StorageInfo* device_info) const override;
40 bool GetMTPStorageInfoFromDeviceId(
41 const std::string& storage_device_id,
42 base::string16* device_location,
43 base::string16* storage_object_id) const override;
45 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_