[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / storage_monitor / storage_monitor_win.h
1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_
6 #define COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_
7
8 #include <windows.h>
9
10 #include <memory>
11
12 #include "components/storage_monitor/storage_monitor.h"
13
14 namespace base {
15 class FilePath;
16 }
17
18 namespace storage_monitor {
19
20 class PortableDeviceWatcherWin;
21 class TestStorageMonitorWin;
22 class VolumeMountWatcherWin;
23
24 class StorageMonitorWin : public StorageMonitor {
25  public:
26   // Should only be called by browser start up code.
27   // Use StorageMonitor::GetInstance() instead.
28   // To support unit tests, this constructor takes |volume_mount_watcher| and
29   // |portable_device_watcher| objects. These params are either constructed in
30   // unit tests or in StorageMonitorWin CreateInternal() function.
31   StorageMonitorWin(
32       std::unique_ptr<VolumeMountWatcherWin> volume_mount_watcher,
33       std::unique_ptr<PortableDeviceWatcherWin> portable_device_watcher);
34
35   StorageMonitorWin(const StorageMonitorWin&) = delete;
36   StorageMonitorWin& operator=(const StorageMonitorWin&) = delete;
37
38   ~StorageMonitorWin() override;
39
40   // Must be called after the file thread is created.
41   void Init() override;
42
43   // StorageMonitor:
44   bool GetStorageInfoForPath(const base::FilePath& path,
45                              StorageInfo* device_info) const override;
46   bool GetMTPStorageInfoFromDeviceId(
47       const std::string& storage_device_id,
48       std::wstring* device_location,
49       std::wstring* storage_object_id) const override;
50   void EjectDevice(const std::string& device_id,
51                    base::OnceCallback<void(EjectStatus)> callback) override;
52
53  private:
54   class PortableDeviceNotifications;
55   friend class TestStorageMonitorWin;
56
57   void MediaChangeNotificationRegister();
58
59   // Gets the removable storage information given a |device_path|. On success,
60   // returns true and fills in |info|.
61   bool GetDeviceInfo(const base::FilePath& device_path,
62                      StorageInfo* info) const;
63
64   static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam,
65                                        LPARAM lparam);
66
67   LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam,
68                            LPARAM lparam);
69
70   void OnDeviceChange(UINT event_type, LPARAM data);
71   void OnMediaChange(WPARAM wparam, LPARAM lparam);
72
73   // The window class of |window_|.
74   ATOM window_class_ = 0;
75
76   // The handle of the module that contains the window procedure of |window_|.
77   HMODULE instance_ = nullptr;
78   HWND window_ = nullptr;
79
80   // The handle of a registration for shell notifications.
81   ULONG shell_change_notify_id_ = 0;
82
83   // The volume mount point watcher, used to manage the mounted devices.
84   const std::unique_ptr<VolumeMountWatcherWin> volume_mount_watcher_;
85
86   // The portable device watcher, used to manage media transfer protocol
87   // devices.
88   const std::unique_ptr<PortableDeviceWatcherWin> portable_device_watcher_;
89 };
90
91 }  // namespace storage_monitor
92
93 #endif  // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_