Commit cd66eab2 authored by kmadhusu@chromium.org's avatar kmadhusu@chromium.org

Retry: [CrOS] Enumerate existing mount points and check for media devices.

Fixed unit test failures.

Original review CL: http://codereview.chromium.org/10843061

BUG=none
TEST=none


Review URL: https://chromiumcodereview.appspot.com/10830165

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149936 0039d316-1c4b-4281-b951-d872f2087c98
parent b8c15ec6
...@@ -51,6 +51,8 @@ MockDiskMountManager::MockDiskMountManager() { ...@@ -51,6 +51,8 @@ MockDiskMountManager::MockDiskMountManager() {
&MockDiskMountManager::RemoveObserverInternal)); &MockDiskMountManager::RemoveObserverInternal));
ON_CALL(*this, disks()) ON_CALL(*this, disks())
.WillByDefault(Invoke(this, &MockDiskMountManager::disksInternal)); .WillByDefault(Invoke(this, &MockDiskMountManager::disksInternal));
ON_CALL(*this, mount_points())
.WillByDefault(Invoke(this, &MockDiskMountManager::mountPointsInternal));
} }
MockDiskMountManager::~MockDiskMountManager() { MockDiskMountManager::~MockDiskMountManager() {
...@@ -143,6 +145,8 @@ void MockDiskMountManager::SetupDefaultReplies() { ...@@ -143,6 +145,8 @@ void MockDiskMountManager::SetupDefaultReplies() {
.Times(AnyNumber()); .Times(AnyNumber());
EXPECT_CALL(*this, disks()) EXPECT_CALL(*this, disks())
.WillRepeatedly(ReturnRef(disks_)); .WillRepeatedly(ReturnRef(disks_));
EXPECT_CALL(*this, mount_points())
.WillRepeatedly(ReturnRef(mount_points_));
EXPECT_CALL(*this, RequestMountInfoRefresh()) EXPECT_CALL(*this, RequestMountInfoRefresh())
.Times(AnyNumber()); .Times(AnyNumber());
EXPECT_CALL(*this, MountPath(_, _, _, _)) EXPECT_CALL(*this, MountPath(_, _, _, _))
...@@ -193,6 +197,11 @@ void MockDiskMountManager::RemoveDiskEntryForMountDevice( ...@@ -193,6 +197,11 @@ void MockDiskMountManager::RemoveDiskEntryForMountDevice(
} }
} }
const DiskMountManager::MountPointMap&
MockDiskMountManager::mountPointsInternal() const {
return mount_points_;
}
void MockDiskMountManager::NotifyDiskChanged( void MockDiskMountManager::NotifyDiskChanged(
DiskMountManagerEventType event, DiskMountManagerEventType event,
const DiskMountManager::Disk* disk) { const DiskMountManager::Disk* disk) {
......
...@@ -69,6 +69,9 @@ class MockDiskMountManager : public DiskMountManager { ...@@ -69,6 +69,9 @@ class MockDiskMountManager : public DiskMountManager {
// Is used to implement disks. // Is used to implement disks.
const DiskMountManager::DiskMap& disksInternal() const { return disks_; } const DiskMountManager::DiskMap& disksInternal() const { return disks_; }
// This function is primarily for MediaDeviceNotificationsTest.
const DiskMountManager::MountPointMap& mountPointsInternal() const;
// Notifies observers about device status update. // Notifies observers about device status update.
void NotifyDeviceChanged(DiskMountManagerEventType event, void NotifyDeviceChanged(DiskMountManagerEventType event,
const std::string& path); const std::string& path);
...@@ -83,6 +86,9 @@ class MockDiskMountManager : public DiskMountManager { ...@@ -83,6 +86,9 @@ class MockDiskMountManager : public DiskMountManager {
// The list of disks found. // The list of disks found.
DiskMountManager::DiskMap disks_; DiskMountManager::DiskMap disks_;
// The list of existing mount points.
DiskMountManager::MountPointMap mount_points_;
DISALLOW_COPY_AND_ASSIGN(MockDiskMountManager); DISALLOW_COPY_AND_ASSIGN(MockDiskMountManager);
}; };
......
...@@ -46,6 +46,7 @@ using content::BrowserThread; ...@@ -46,6 +46,7 @@ using content::BrowserThread;
MediaDeviceNotifications::MediaDeviceNotifications() { MediaDeviceNotifications::MediaDeviceNotifications() {
DCHECK(disks::DiskMountManager::GetInstance()); DCHECK(disks::DiskMountManager::GetInstance());
disks::DiskMountManager::GetInstance()->AddObserver(this); disks::DiskMountManager::GetInstance()->AddObserver(this);
CheckExistingMountPointsOnUIThread();
} }
MediaDeviceNotifications::~MediaDeviceNotifications() { MediaDeviceNotifications::~MediaDeviceNotifications() {
...@@ -55,6 +56,19 @@ MediaDeviceNotifications::~MediaDeviceNotifications() { ...@@ -55,6 +56,19 @@ MediaDeviceNotifications::~MediaDeviceNotifications() {
} }
} }
void MediaDeviceNotifications::CheckExistingMountPointsOnUIThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const disks::DiskMountManager::MountPointMap& mount_point_map =
disks::DiskMountManager::GetInstance()->mount_points();
for (disks::DiskMountManager::MountPointMap::const_iterator it =
mount_point_map.begin(); it != mount_point_map.end(); ++it) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(&MediaDeviceNotifications::CheckMountedPathOnFileThread,
this, it->second));
}
}
void MediaDeviceNotifications::DiskChanged( void MediaDeviceNotifications::DiskChanged(
disks::DiskMountManagerEventType event, disks::DiskMountManagerEventType event,
const disks::DiskMountManager::Disk* disk) { const disks::DiskMountManager::Disk* disk) {
......
...@@ -47,6 +47,10 @@ class MediaDeviceNotifications ...@@ -47,6 +47,10 @@ class MediaDeviceNotifications
// Private to avoid code deleting the object. // Private to avoid code deleting the object.
virtual ~MediaDeviceNotifications(); virtual ~MediaDeviceNotifications();
// Checks existing mount points map for media devices. For each mount point,
// call CheckMountedPathOnFileThread() below.
void CheckExistingMountPointsOnUIThread();
// Checks if the mount point in |mount_info| is a media device. If it is, // Checks if the mount point in |mount_info| is a media device. If it is,
// then continue with AddMountedPathOnUIThread() below. // then continue with AddMountedPathOnUIThread() below.
void CheckMountedPathOnFileThread( void CheckMountedPathOnFileThread(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment