Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / components / storage_monitor / test_volume_mount_watcher_win.h
blob267d096078058d3828c4c45675f38f3348568487
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.
4 //
5 // This file contains a subclass of VolumeMountWatcherWin to expose some
6 // functionality for testing.
8 #ifndef COMPONENTS_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_
9 #define COMPONENTS_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_
11 #include <string>
12 #include <vector>
14 #include "base/strings/string16.h"
15 #include "base/synchronization/waitable_event.h"
16 #include "components/storage_monitor/volume_mount_watcher_win.h"
18 namespace base {
19 class FilePath;
22 namespace storage_monitor {
24 class TestVolumeMountWatcherWin : public VolumeMountWatcherWin {
25 public:
26 TestVolumeMountWatcherWin();
27 virtual ~TestVolumeMountWatcherWin();
29 static bool GetDeviceRemovable(const base::FilePath& device_path,
30 bool* removable);
32 void AddDeviceForTesting(const base::FilePath& device_path,
33 const std::string& device_id,
34 const base::string16& device_name,
35 uint64 total_size_in_bytes);
37 void SetAttachedDevicesFake();
39 void FlushWorkerPoolForTesting();
41 const std::vector<base::FilePath>& devices_checked() const {
42 return devices_checked_;
45 void BlockDeviceCheckForTesting();
47 void ReleaseDeviceCheck();
49 // VolumeMountWatcherWin:
50 virtual void DeviceCheckComplete(const base::FilePath& device_path) override;
51 virtual GetAttachedDevicesCallbackType
52 GetAttachedDevicesCallback() const override;
53 virtual GetDeviceDetailsCallbackType
54 GetDeviceDetailsCallback() const override;
56 // Should be used by unit tests to make sure the worker pool doesn't survive
57 // into other test runs.
58 void ShutdownWorkerPool();
60 private:
61 std::vector<base::FilePath> devices_checked_;
62 scoped_ptr<base::WaitableEvent> device_check_complete_event_;
63 bool attached_devices_fake_;
65 DISALLOW_COPY_AND_ASSIGN(TestVolumeMountWatcherWin);
68 } // namespace storage_monitor
70 #endif // COMPONENTS_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_