| 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 | 28 // To support unit tests, this constructor takes |volume_mount_watcher| and |
| 29 // start up code. Use GetInstance() instead. | 29 // |portable_device_watcher| objects. These params are either constructed in |
| 30 static StorageMonitorWin* Create(); | 30 // unit tests or in StorageMonitorWin::Create() function. |
| 31 | 31 StorageMonitorWin(VolumeMountWatcherWin* volume_mount_watcher, |
| 32 PortableDeviceWatcherWin* portable_device_watcher); |
| 32 virtual ~StorageMonitorWin(); | 33 virtual ~StorageMonitorWin(); |
| 33 | 34 |
| 34 // Must be called after the file thread is created. | 35 // Must be called after the file thread is created. |
| 35 virtual void Init() OVERRIDE; | 36 virtual void Init() OVERRIDE; |
| 36 | 37 |
| 37 // StorageMonitor: | 38 // StorageMonitor: |
| 38 virtual bool GetStorageInfoForPath(const base::FilePath& path, | 39 virtual bool GetStorageInfoForPath(const base::FilePath& path, |
| 39 StorageInfo* device_info) const OVERRIDE; | 40 StorageInfo* device_info) const OVERRIDE; |
| 40 virtual bool GetMTPStorageInfoFromDeviceId( | 41 virtual bool GetMTPStorageInfoFromDeviceId( |
| 41 const std::string& storage_device_id, | 42 const std::string& storage_device_id, |
| 42 base::string16* device_location, | 43 base::string16* device_location, |
| 43 base::string16* storage_object_id) const OVERRIDE; | 44 base::string16* storage_object_id) const OVERRIDE; |
| 44 | 45 |
| 45 virtual void EjectDevice( | 46 virtual void EjectDevice( |
| 46 const std::string& device_id, | 47 const std::string& device_id, |
| 47 base::Callback<void(EjectStatus)> callback) OVERRIDE; | 48 base::Callback<void(EjectStatus)> callback) OVERRIDE; |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 class PortableDeviceNotifications; | 51 class PortableDeviceNotifications; |
| 51 friend class test::TestStorageMonitorWin; | 52 friend class test::TestStorageMonitorWin; |
| 52 | 53 |
| 53 // To support unit tests, this constructor takes |volume_mount_watcher| and | |
| 54 // |portable_device_watcher| objects. These params are either constructed in | |
| 55 // unit tests or in StorageMonitorWin::Create() function. | |
| 56 StorageMonitorWin(VolumeMountWatcherWin* volume_mount_watcher, | |
| 57 PortableDeviceWatcherWin* portable_device_watcher); | |
| 58 | |
| 59 // Gets the removable storage information given a |device_path|. On success, | 54 // Gets the removable storage information given a |device_path|. On success, |
| 60 // returns true and fills in |info|. | 55 // returns true and fills in |info|. |
| 61 bool GetDeviceInfo(const base::FilePath& device_path, | 56 bool GetDeviceInfo(const base::FilePath& device_path, |
| 62 StorageInfo* info) const; | 57 StorageInfo* info) const; |
| 63 | 58 |
| 64 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, | 59 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, |
| 65 LPARAM lparam); | 60 LPARAM lparam); |
| 66 | 61 |
| 67 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, | 62 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, |
| 68 LPARAM lparam); | 63 LPARAM lparam); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 82 // The portable device watcher, used to manage media transfer protocol | 77 // The portable device watcher, used to manage media transfer protocol |
| 83 // devices. | 78 // devices. |
| 84 scoped_ptr<PortableDeviceWatcherWin> portable_device_watcher_; | 79 scoped_ptr<PortableDeviceWatcherWin> portable_device_watcher_; |
| 85 | 80 |
| 86 DISALLOW_COPY_AND_ASSIGN(StorageMonitorWin); | 81 DISALLOW_COPY_AND_ASSIGN(StorageMonitorWin); |
| 87 }; | 82 }; |
| 88 | 83 |
| 89 } // namespace chrome | 84 } // namespace chrome |
| 90 | 85 |
| 91 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ | 86 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ |
| OLD | NEW |