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