1// Copyright 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_CHROMEOS_FILE_MANAGER_FAKE_DISK_MOUNT_MANAGER_H_ 6#define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FAKE_DISK_MOUNT_MANAGER_H_ 7 8#include <string> 9#include <vector> 10 11#include "base/basictypes.h" 12#include "base/compiler_specific.h" 13#include "base/observer_list.h" 14#include "chromeos/dbus/cros_disks_client.h" 15#include "chromeos/disks/disk_mount_manager.h" 16 17namespace file_manager { 18 19class FakeDiskMountManager : public chromeos::disks::DiskMountManager { 20 public: 21 struct MountRequest { 22 MountRequest(const std::string& source_path, 23 const std::string& source_format, 24 const std::string& mount_label, 25 chromeos::MountType type); 26 27 std::string source_path; 28 std::string source_format; 29 std::string mount_label; 30 chromeos::MountType type; 31 }; 32 33 struct UnmountRequest { 34 UnmountRequest(const std::string& mount_path, 35 chromeos::UnmountOptions options); 36 37 std::string mount_path; 38 chromeos::UnmountOptions options; 39 }; 40 41 FakeDiskMountManager(); 42 virtual ~FakeDiskMountManager(); 43 44 const std::vector<MountRequest>& mount_requests() const { 45 return mount_requests_; 46 } 47 const std::vector<UnmountRequest>& unmount_requests() const { 48 return unmount_requests_; 49 } 50 51 // DiskMountManager overrides. 52 virtual void AddObserver(Observer* observer) OVERRIDE; 53 virtual void RemoveObserver(Observer* observer) OVERRIDE; 54 virtual const DiskMap& disks() const OVERRIDE; 55 virtual const Disk* FindDiskBySourcePath( 56 const std::string& source_path) const OVERRIDE; 57 virtual const MountPointMap& mount_points() const OVERRIDE; 58 virtual void RequestMountInfoRefresh() OVERRIDE; 59 virtual void MountPath(const std::string& source_path, 60 const std::string& source_format, 61 const std::string& mount_label, 62 chromeos::MountType type) OVERRIDE; 63 virtual void UnmountPath(const std::string& mount_path, 64 chromeos::UnmountOptions options, 65 const UnmountPathCallback& callback) OVERRIDE; 66 virtual void FormatMountedDevice(const std::string& mount_path) OVERRIDE; 67 virtual void UnmountDeviceRecursively( 68 const std::string& device_path, 69 const UnmountDeviceRecursivelyCallbackType& callback) OVERRIDE; 70 71 virtual bool AddDiskForTest(Disk* disk) OVERRIDE; 72 virtual bool AddMountPointForTest( 73 const MountPointInfo& mount_point) OVERRIDE; 74 void InvokeDiskEventForTest(DiskEvent event, const Disk* disk); 75 76 private: 77 ObserverList<Observer> observers_; 78 79 DiskMap disks_; 80 MountPointMap mount_points_; 81 82 std::vector<MountRequest> mount_requests_; 83 std::vector<UnmountRequest> unmount_requests_; 84 85 DISALLOW_COPY_AND_ASSIGN(FakeDiskMountManager); 86}; 87 88} // namespace file_manager 89 90#endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FAKE_DISK_MOUNT_MANAGER_H_ 91