| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 // This file contains a subclass of VolumeMountWatcherWin to expose some | 5 // This file contains a subclass of VolumeMountWatcherWin to expose some | 
| 6 // functionality for testing. | 6 // functionality for testing. | 
| 7 | 7 | 
| 8 #ifndef COMPONENTS_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_ | 8 #ifndef COMPONENTS_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_ | 
| 9 #define COMPONENTS_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_ | 9 #define COMPONENTS_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_ | 
| 10 | 10 | 
|  | 11 #include <stdint.h> | 
|  | 12 | 
| 11 #include <string> | 13 #include <string> | 
| 12 #include <vector> | 14 #include <vector> | 
| 13 | 15 | 
|  | 16 #include "base/macros.h" | 
| 14 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" | 
| 15 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" | 
| 16 #include "components/storage_monitor/volume_mount_watcher_win.h" | 19 #include "components/storage_monitor/volume_mount_watcher_win.h" | 
| 17 | 20 | 
| 18 namespace base { | 21 namespace base { | 
| 19 class FilePath; | 22 class FilePath; | 
| 20 } | 23 } | 
| 21 | 24 | 
| 22 namespace storage_monitor { | 25 namespace storage_monitor { | 
| 23 | 26 | 
| 24 class TestVolumeMountWatcherWin : public VolumeMountWatcherWin { | 27 class TestVolumeMountWatcherWin : public VolumeMountWatcherWin { | 
| 25  public: | 28  public: | 
| 26   TestVolumeMountWatcherWin(); | 29   TestVolumeMountWatcherWin(); | 
| 27   ~TestVolumeMountWatcherWin() override; | 30   ~TestVolumeMountWatcherWin() override; | 
| 28 | 31 | 
| 29   static bool GetDeviceRemovable(const base::FilePath& device_path, | 32   static bool GetDeviceRemovable(const base::FilePath& device_path, | 
| 30                                  bool* removable); | 33                                  bool* removable); | 
| 31 | 34 | 
| 32   void AddDeviceForTesting(const base::FilePath& device_path, | 35   void AddDeviceForTesting(const base::FilePath& device_path, | 
| 33                            const std::string& device_id, | 36                            const std::string& device_id, | 
| 34                            const base::string16& device_name, | 37                            const base::string16& device_name, | 
| 35                            uint64 total_size_in_bytes); | 38                            uint64_t total_size_in_bytes); | 
| 36 | 39 | 
| 37   void SetAttachedDevicesFake(); | 40   void SetAttachedDevicesFake(); | 
| 38 | 41 | 
| 39   void FlushWorkerPoolForTesting(); | 42   void FlushWorkerPoolForTesting(); | 
| 40 | 43 | 
| 41   const std::vector<base::FilePath>& devices_checked() const { | 44   const std::vector<base::FilePath>& devices_checked() const { | 
| 42       return devices_checked_; | 45       return devices_checked_; | 
| 43   } | 46   } | 
| 44 | 47 | 
| 45   void BlockDeviceCheckForTesting(); | 48   void BlockDeviceCheckForTesting(); | 
| 46 | 49 | 
| 47   void ReleaseDeviceCheck(); | 50   void ReleaseDeviceCheck(); | 
| 48 | 51 | 
| 49   // VolumeMountWatcherWin: | 52   // VolumeMountWatcherWin: | 
| 50   void DeviceCheckComplete(const base::FilePath& device_path) override; | 53   void DeviceCheckComplete(const base::FilePath& device_path) override; | 
| 51   GetAttachedDevicesCallbackType GetAttachedDevicesCallback() const override; | 54   GetAttachedDevicesCallbackType GetAttachedDevicesCallback() const override; | 
| 52   GetDeviceDetailsCallbackType GetDeviceDetailsCallback() const override; | 55   GetDeviceDetailsCallbackType GetDeviceDetailsCallback() const override; | 
| 53 | 56 | 
| 54  private: | 57  private: | 
| 55   std::vector<base::FilePath> devices_checked_; | 58   std::vector<base::FilePath> devices_checked_; | 
| 56   scoped_ptr<base::WaitableEvent> device_check_complete_event_; | 59   scoped_ptr<base::WaitableEvent> device_check_complete_event_; | 
| 57   bool attached_devices_fake_; | 60   bool attached_devices_fake_; | 
| 58 | 61 | 
| 59   DISALLOW_COPY_AND_ASSIGN(TestVolumeMountWatcherWin); | 62   DISALLOW_COPY_AND_ASSIGN(TestVolumeMountWatcherWin); | 
| 60 }; | 63 }; | 
| 61 | 64 | 
| 62 }  // namespace storage_monitor | 65 }  // namespace storage_monitor | 
| 63 | 66 | 
| 64 #endif  // COMPONENTS_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_ | 67 #endif  // COMPONENTS_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_ | 
| OLD | NEW | 
|---|