Implement multiple alternative services per origin.
[chromium-blink-merge.git] / components / storage_monitor / test_storage_monitor.h
blobda3809b0d1e329c3de47ff0fcecf42e93584ae3b
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.
5 #ifndef COMPONENTS_STORAGE_MONITOR_TEST_STORAGE_MONITOR_H_
6 #define COMPONENTS_STORAGE_MONITOR_TEST_STORAGE_MONITOR_H_
8 #include <string>
10 #include "components/storage_monitor/storage_monitor.h"
12 namespace storage_monitor {
14 class TestStorageMonitor : public StorageMonitor {
15 public:
16 TestStorageMonitor();
17 ~TestStorageMonitor() override;
19 void Init() override;
21 void MarkInitialized();
23 // Create and initialize a new TestStorageMonitor and install it
24 // as the StorageMonitor singleton. If there is a StorageMonitor instance
25 // already in place, NULL is returned, otherwise the TestStorageMonitor
26 // instance is returned. Use |Destroy| to delete the singleton.
27 static TestStorageMonitor* CreateAndInstall();
29 // Create and initialize a new TestStorageMonitor and install it
30 // as the StorageMonitor singleton. TestStorageMonitor is returned for
31 // convenience. Use |Destroy| to delete the singleton.
32 static TestStorageMonitor* CreateForBrowserTests();
34 // Synchronously initialize the current storage monitor.
35 static void SyncInitialize();
37 bool GetStorageInfoForPath(const base::FilePath& path,
38 StorageInfo* device_info) const override;
40 #if defined(OS_WIN)
41 bool GetMTPStorageInfoFromDeviceId(
42 const std::string& storage_device_id,
43 base::string16* device_location,
44 base::string16* storage_object_id) const override;
45 #endif
47 #if defined(OS_LINUX)
48 device::MediaTransferProtocolManager* media_transfer_protocol_manager()
49 override;
50 #endif
52 Receiver* receiver() const override;
54 void EjectDevice(
55 const std::string& device_id,
56 base::Callback<void(StorageMonitor::EjectStatus)> callback) override;
58 const std::string& ejected_device() const { return ejected_device_; }
60 void AddRemovablePath(const base::FilePath& path);
62 bool init_called() const { return init_called_; }
64 private:
65 // Whether TestStorageMonitor::Init() has been called for not.
66 bool init_called_;
68 // The last device to be ejected.
69 std::string ejected_device_;
71 // Paths considered for testing purposes to be on removable storage.
72 std::vector<base::FilePath> removable_paths_;
74 #if defined(OS_LINUX)
75 scoped_ptr<device::MediaTransferProtocolManager>
76 media_transfer_protocol_manager_;
77 #endif
80 } // namespace storage_monitor
82 #endif // COMPONENTS_STORAGE_MONITOR_TEST_STORAGE_MONITOR_H_