diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-07 01:08:57 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-07 01:08:57 +0000 |
commit | bcfa007f7f77709443d15f41307c9d3f8a6d6173 (patch) | |
tree | 6eb3f2f8255d7f667e4eddd629830e01a61a8eaf /chrome/browser/chromeos/disks | |
parent | d5b6684366b6c3e3f0af682126b4828c71bbc16a (diff) | |
download | chromium_src-bcfa007f7f77709443d15f41307c9d3f8a6d6173.zip chromium_src-bcfa007f7f77709443d15f41307c9d3f8a6d6173.tar.gz chromium_src-bcfa007f7f77709443d15f41307c9d3f8a6d6173.tar.bz2 |
Created a helper function "FindDiskBySourcePath" in DiskMountManager.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10829160
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150205 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/disks')
4 files changed, 28 insertions, 1 deletions
diff --git a/chrome/browser/chromeos/disks/disk_mount_manager.cc b/chrome/browser/chromeos/disks/disk_mount_manager.cc index 98e24ac..388259c 100644 --- a/chrome/browser/chromeos/disks/disk_mount_manager.cc +++ b/chrome/browser/chromeos/disks/disk_mount_manager.cc @@ -230,6 +230,12 @@ class DiskMountManagerImpl : public DiskMountManager { // DiskMountManager override. const DiskMap& disks() const OVERRIDE { return disks_; } + // DiskMountManager override. + virtual const Disk* FindDiskBySourcePath(const std::string& source_path) + const OVERRIDE { + DiskMap::const_iterator disk_it = disks_.find(source_path); + return disk_it == disks_.end() ? NULL : disk_it->second; + } // DiskMountManager override. const MountPointMap& mount_points() const OVERRIDE { return mount_points_; } diff --git a/chrome/browser/chromeos/disks/disk_mount_manager.h b/chrome/browser/chromeos/disks/disk_mount_manager.h index df6dd18..546c4b7 100644 --- a/chrome/browser/chromeos/disks/disk_mount_manager.h +++ b/chrome/browser/chromeos/disks/disk_mount_manager.h @@ -198,6 +198,10 @@ class DiskMountManager { // Gets the list of disks found. virtual const DiskMap& disks() const = 0; + // Returns Disk object corresponding to |source_path| or NULL on failure. + virtual const Disk* FindDiskBySourcePath( + const std::string& source_path) const = 0; + // Gets the list of mount points. virtual const MountPointMap& mount_points() const = 0; diff --git a/chrome/browser/chromeos/disks/mock_disk_mount_manager.cc b/chrome/browser/chromeos/disks/mock_disk_mount_manager.cc index 3890965..de08ebe 100644 --- a/chrome/browser/chromeos/disks/mock_disk_mount_manager.cc +++ b/chrome/browser/chromeos/disks/mock_disk_mount_manager.cc @@ -53,6 +53,9 @@ MockDiskMountManager::MockDiskMountManager() { .WillByDefault(Invoke(this, &MockDiskMountManager::disksInternal)); ON_CALL(*this, mount_points()) .WillByDefault(Invoke(this, &MockDiskMountManager::mountPointsInternal)); + ON_CALL(*this, FindDiskBySourcePath(_)) + .WillByDefault(Invoke( + this, &MockDiskMountManager::FindDiskBySourcePathInternal)); } MockDiskMountManager::~MockDiskMountManager() { @@ -147,6 +150,8 @@ void MockDiskMountManager::SetupDefaultReplies() { .WillRepeatedly(ReturnRef(disks_)); EXPECT_CALL(*this, mount_points()) .WillRepeatedly(ReturnRef(mount_points_)); + EXPECT_CALL(*this, FindDiskBySourcePath(_)) + .Times(AnyNumber()); EXPECT_CALL(*this, RequestMountInfoRefresh()) .Times(AnyNumber()); EXPECT_CALL(*this, MountPath(_, _, _, _)) @@ -202,6 +207,13 @@ MockDiskMountManager::mountPointsInternal() const { return mount_points_; } +const DiskMountManager::Disk* +MockDiskMountManager::FindDiskBySourcePathInternal( + const std::string& source_path) const { + DiskMap::const_iterator disk_it = disks_.find(source_path); + return disk_it == disks_.end() ? NULL : disk_it->second; +} + void MockDiskMountManager::NotifyDiskChanged( DiskMountManagerEventType event, const DiskMountManager::Disk* disk) { diff --git a/chrome/browser/chromeos/disks/mock_disk_mount_manager.h b/chrome/browser/chromeos/disks/mock_disk_mount_manager.h index 78d787b..aec2894 100644 --- a/chrome/browser/chromeos/disks/mock_disk_mount_manager.h +++ b/chrome/browser/chromeos/disks/mock_disk_mount_manager.h @@ -26,6 +26,8 @@ class MockDiskMountManager : public DiskMountManager { MOCK_METHOD1(AddObserver, void(DiskMountManager::Observer*)); MOCK_METHOD1(RemoveObserver, void(DiskMountManager::Observer*)); MOCK_CONST_METHOD0(disks, const DiskMountManager::DiskMap&(void)); + MOCK_CONST_METHOD1(FindDiskBySourcePath, + const DiskMountManager::Disk*(const std::string&)); MOCK_CONST_METHOD0(mount_points, const DiskMountManager::MountPointMap&(void)); MOCK_METHOD0(RequestMountInfoRefresh, void(void)); @@ -69,9 +71,12 @@ class MockDiskMountManager : public DiskMountManager { // Is used to implement disks. const DiskMountManager::DiskMap& disksInternal() const { return disks_; } - // This function is primarily for MediaDeviceNotificationsTest. const DiskMountManager::MountPointMap& mountPointsInternal() const; + // Returns Disk object associated with the |source_path| or NULL on failure. + const DiskMountManager::Disk* FindDiskBySourcePathInternal( + const std::string& source_path) const; + // Notifies observers about device status update. void NotifyDeviceChanged(DiskMountManagerEventType event, const std::string& path); |