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 #ifndef COMPONENTS_STORAGE_MONITOR_TEST_STORAGE_MONITOR_H_ | 5 #ifndef COMPONENTS_STORAGE_MONITOR_TEST_STORAGE_MONITOR_H_ |
6 #define COMPONENTS_STORAGE_MONITOR_TEST_STORAGE_MONITOR_H_ | 6 #define COMPONENTS_STORAGE_MONITOR_TEST_STORAGE_MONITOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "components/storage_monitor/storage_monitor.h" | 10 #include "components/storage_monitor/storage_monitor.h" |
11 | 11 |
12 namespace storage_monitor { | 12 namespace storage_monitor { |
13 | 13 |
14 class TestStorageMonitor : public StorageMonitor { | 14 class TestStorageMonitor : public StorageMonitor { |
15 public: | 15 public: |
16 TestStorageMonitor(); | 16 TestStorageMonitor(); |
17 virtual ~TestStorageMonitor(); | 17 ~TestStorageMonitor() override; |
18 | 18 |
19 virtual void Init() override; | 19 void Init() override; |
20 | 20 |
21 void MarkInitialized(); | 21 void MarkInitialized(); |
22 | 22 |
23 // Create and initialize a new TestStorageMonitor and install it | 23 // Create and initialize a new TestStorageMonitor and install it |
24 // as the StorageMonitor singleton. If there is a StorageMonitor instance | 24 // as the StorageMonitor singleton. If there is a StorageMonitor instance |
25 // already in place, NULL is returned, otherwise the TestStorageMonitor | 25 // already in place, NULL is returned, otherwise the TestStorageMonitor |
26 // instance is returned. Use |Destroy| to delete the singleton. | 26 // instance is returned. Use |Destroy| to delete the singleton. |
27 static TestStorageMonitor* CreateAndInstall(); | 27 static TestStorageMonitor* CreateAndInstall(); |
28 | 28 |
29 // Create and initialize a new TestStorageMonitor and install it | 29 // Create and initialize a new TestStorageMonitor and install it |
30 // as the StorageMonitor singleton. TestStorageMonitor is returned for | 30 // as the StorageMonitor singleton. TestStorageMonitor is returned for |
31 // convenience. Use |Destroy| to delete the singleton. | 31 // convenience. Use |Destroy| to delete the singleton. |
32 static TestStorageMonitor* CreateForBrowserTests(); | 32 static TestStorageMonitor* CreateForBrowserTests(); |
33 | 33 |
34 // Synchronously initialize the current storage monitor. | 34 // Synchronously initialize the current storage monitor. |
35 static void SyncInitialize(); | 35 static void SyncInitialize(); |
36 | 36 |
37 virtual bool GetStorageInfoForPath( | 37 bool GetStorageInfoForPath(const base::FilePath& path, |
38 const base::FilePath& path, | 38 StorageInfo* device_info) const override; |
39 StorageInfo* device_info) const override; | |
40 | 39 |
41 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
42 virtual bool GetMTPStorageInfoFromDeviceId( | 41 virtual bool GetMTPStorageInfoFromDeviceId( |
43 const std::string& storage_device_id, | 42 const std::string& storage_device_id, |
44 base::string16* device_location, | 43 base::string16* device_location, |
45 base::string16* storage_object_id) const override; | 44 base::string16* storage_object_id) const override; |
46 #endif | 45 #endif |
47 | 46 |
48 #if defined(OS_LINUX) | 47 #if defined(OS_LINUX) |
49 virtual device::MediaTransferProtocolManager* | 48 virtual device::MediaTransferProtocolManager* |
50 media_transfer_protocol_manager() override; | 49 media_transfer_protocol_manager() override; |
51 #endif | 50 #endif |
52 | 51 |
53 virtual Receiver* receiver() const override; | 52 Receiver* receiver() const override; |
54 | 53 |
55 virtual void EjectDevice( | 54 void EjectDevice( |
56 const std::string& device_id, | 55 const std::string& device_id, |
57 base::Callback<void(StorageMonitor::EjectStatus)> callback) | 56 base::Callback<void(StorageMonitor::EjectStatus)> callback) override; |
58 override; | |
59 | 57 |
60 const std::string& ejected_device() const { return ejected_device_; } | 58 const std::string& ejected_device() const { return ejected_device_; } |
61 | 59 |
62 bool init_called() const { return init_called_; } | 60 bool init_called() const { return init_called_; } |
63 | 61 |
64 private: | 62 private: |
65 // Whether TestStorageMonitor::Init() has been called for not. | 63 // Whether TestStorageMonitor::Init() has been called for not. |
66 bool init_called_; | 64 bool init_called_; |
67 | 65 |
68 // The last device to be ejected. | 66 // The last device to be ejected. |
69 std::string ejected_device_; | 67 std::string ejected_device_; |
70 | 68 |
71 #if defined(OS_LINUX) | 69 #if defined(OS_LINUX) |
72 scoped_ptr<device::MediaTransferProtocolManager> | 70 scoped_ptr<device::MediaTransferProtocolManager> |
73 media_transfer_protocol_manager_; | 71 media_transfer_protocol_manager_; |
74 #endif | 72 #endif |
75 }; | 73 }; |
76 | 74 |
77 } // namespace storage_monitor | 75 } // namespace storage_monitor |
78 | 76 |
79 #endif // COMPONENTS_STORAGE_MONITOR_TEST_STORAGE_MONITOR_H_ | 77 #endif // COMPONENTS_STORAGE_MONITOR_TEST_STORAGE_MONITOR_H_ |
OLD | NEW |