OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ | 5 #ifndef CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ |
6 #define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ | 6 #define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "chrome/browser/storage_monitor/storage_monitor.h" | 11 #include "chrome/browser/storage_monitor/storage_monitor.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class FilePath; | 14 class FilePath; |
15 } | 15 } |
16 | 16 |
17 namespace chrome { | 17 namespace chrome { |
18 | 18 |
19 namespace test { | 19 namespace test { |
20 class TestStorageMonitorWin; | 20 class TestStorageMonitorWin; |
21 } | 21 } |
22 | 22 |
23 class PortableDeviceWatcherWin; | 23 class PortableDeviceWatcherWin; |
24 class VolumeMountWatcherWin; | 24 class VolumeMountWatcherWin; |
25 | 25 |
26 class StorageMonitorWin : public StorageMonitor { | 26 class StorageMonitorWin : public StorageMonitor { |
27 public: | 27 public: |
28 // Creates an instance of StorageMonitorWin. Should only be called by browser | |
29 // start up code. Use GetInstance() instead. | |
30 static StorageMonitorWin* Create(); | |
31 | |
32 virtual ~StorageMonitorWin(); | 28 virtual ~StorageMonitorWin(); |
33 | 29 |
34 // Must be called after the file thread is created. | 30 // Must be called after the file thread is created. |
35 virtual void Init() OVERRIDE; | 31 virtual void Init() OVERRIDE; |
36 | 32 |
37 // StorageMonitor: | 33 // StorageMonitor: |
38 virtual bool GetStorageInfoForPath(const base::FilePath& path, | 34 virtual bool GetStorageInfoForPath(const base::FilePath& path, |
39 StorageInfo* device_info) const OVERRIDE; | 35 StorageInfo* device_info) const OVERRIDE; |
40 virtual bool GetMTPStorageInfoFromDeviceId( | 36 virtual bool GetMTPStorageInfoFromDeviceId( |
41 const std::string& storage_device_id, | 37 const std::string& storage_device_id, |
42 base::string16* device_location, | 38 base::string16* device_location, |
43 base::string16* storage_object_id) const OVERRIDE; | 39 base::string16* storage_object_id) const OVERRIDE; |
44 | 40 |
45 virtual void EjectDevice( | 41 virtual void EjectDevice( |
46 const std::string& device_id, | 42 const std::string& device_id, |
47 base::Callback<void(EjectStatus)> callback) OVERRIDE; | 43 base::Callback<void(EjectStatus)> callback) OVERRIDE; |
48 | 44 |
49 private: | 45 private: |
50 class PortableDeviceNotifications; | 46 class PortableDeviceNotifications; |
51 friend class test::TestStorageMonitorWin; | 47 friend class test::TestStorageMonitorWin; |
| 48 friend StorageMonitor* StorageMonitor::Create(); |
52 | 49 |
53 // To support unit tests, this constructor takes |volume_mount_watcher| and | 50 // To support unit tests, this constructor takes |volume_mount_watcher| and |
54 // |portable_device_watcher| objects. These params are either constructed in | 51 // |portable_device_watcher| objects. These params are either constructed in |
55 // unit tests or in StorageMonitorWin::Create() function. | 52 // unit tests or in StorageMonitorWin Create() function. |
56 StorageMonitorWin(VolumeMountWatcherWin* volume_mount_watcher, | 53 StorageMonitorWin(VolumeMountWatcherWin* volume_mount_watcher, |
57 PortableDeviceWatcherWin* portable_device_watcher); | 54 PortableDeviceWatcherWin* portable_device_watcher); |
58 | 55 |
59 // Gets the removable storage information given a |device_path|. On success, | 56 // Gets the removable storage information given a |device_path|. On success, |
60 // returns true and fills in |info|. | 57 // returns true and fills in |info|. |
61 bool GetDeviceInfo(const base::FilePath& device_path, | 58 bool GetDeviceInfo(const base::FilePath& device_path, |
62 StorageInfo* info) const; | 59 StorageInfo* info) const; |
63 | 60 |
64 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, | 61 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, |
65 LPARAM lparam); | 62 LPARAM lparam); |
(...skipping 16 matching lines...) Expand all Loading... |
82 // The portable device watcher, used to manage media transfer protocol | 79 // The portable device watcher, used to manage media transfer protocol |
83 // devices. | 80 // devices. |
84 scoped_ptr<PortableDeviceWatcherWin> portable_device_watcher_; | 81 scoped_ptr<PortableDeviceWatcherWin> portable_device_watcher_; |
85 | 82 |
86 DISALLOW_COPY_AND_ASSIGN(StorageMonitorWin); | 83 DISALLOW_COPY_AND_ASSIGN(StorageMonitorWin); |
87 }; | 84 }; |
88 | 85 |
89 } // namespace chrome | 86 } // namespace chrome |
90 | 87 |
91 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ | 88 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ |
OLD | NEW |