- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / storage_monitor / test_storage_monitor.h
1 // Copyright (c) 2013 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 CHROME_BROWSER_STORAGE_MONITOR_TEST_STORAGE_MONITOR_H_
6 #define CHROME_BROWSER_STORAGE_MONITOR_TEST_STORAGE_MONITOR_H_
7
8 #include <string>
9
10 #include "chrome/browser/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   // in the TestingBrowserProcess. The TestingBrowserProcess owns the created
23   // TestStorageMonitor, but it is also returned for convenience. If there is
24   // no TestingBrowserProcess to own the TestStorageMonitor, it is destroyed
25   // and the return value is NULL.
26   static TestStorageMonitor* CreateAndInstall();
27
28   // Create and initialize a new TestStorageMonitor, and install it
29   // in the BrowserProcessImpl. (Browser tests use the production browser
30   // process implementation.) The BrowserProcessImpl owns the created
31   // TestStorageMonitor, but it is also returned for convenience.
32   static TestStorageMonitor* CreateForBrowserTests();
33
34   // Remove the singleton StorageMonitor from the TestingBrowserProcess.
35   static void RemoveSingleton();
36
37   // Synchronously initialize the current storage monitor.
38   static void SyncInitialize();
39
40   virtual bool GetStorageInfoForPath(
41       const base::FilePath& path,
42       StorageInfo* device_info) const OVERRIDE;
43
44 #if defined(OS_WIN)
45   virtual bool GetMTPStorageInfoFromDeviceId(
46       const std::string& storage_device_id,
47       string16* device_location,
48       string16* storage_object_id) const OVERRIDE;
49 #endif
50
51 #if defined(OS_LINUX)
52   virtual device::MediaTransferProtocolManager*
53       media_transfer_protocol_manager() OVERRIDE;
54 #endif
55
56   virtual Receiver* receiver() const OVERRIDE;
57
58   virtual void EjectDevice(
59       const std::string& device_id,
60       base::Callback<void(StorageMonitor::EjectStatus)> callback)
61       OVERRIDE;
62
63   const std::string& ejected_device() const { return ejected_device_; }
64
65   bool init_called() const { return init_called_; }
66
67  private:
68   // Whether TestStorageMonitor::Init() has been called for not.
69   bool init_called_;
70
71   // The last device to be ejected.
72   std::string ejected_device_;
73
74 #if defined(OS_LINUX)
75   scoped_ptr<device::MediaTransferProtocolManager>
76       media_transfer_protocol_manager_;
77 #endif
78 };
79
80 #endif  // CHROME_BROWSER_STORAGE_MONITOR_TEST_STORAGE_MONITOR_H_