Skip to content

Commit

Permalink
Refresh mount state when suspend is done.
Browse files Browse the repository at this point in the history
BUG=511996
TEST=None

Review URL: https://codereview.chromium.org/1255123002

Cr-Commit-Position: refs/heads/master@{#340828}
  • Loading branch information
hirono-chromium authored and Commit bot committed Jul 29, 2015
1 parent 19b6d9d commit a4b675d
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ FakeDiskMountManager::mount_points() const {
}

void FakeDiskMountManager::EnsureMountInfoRefreshed(
const EnsureMountInfoRefreshedCallback& callback) {
const EnsureMountInfoRefreshedCallback& callback,
bool force) {
callback.Run(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class FakeDiskMountManager : public chromeos::disks::DiskMountManager {
const std::string& source_path) const override;
const MountPointMap& mount_points() const override;
void EnsureMountInfoRefreshed(
const EnsureMountInfoRefreshedCallback& callback) override;
const EnsureMountInfoRefreshedCallback& callback,
bool force) override;
void MountPath(const std::string& source_path,
const std::string& source_format,
const std::string& mount_label,
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/chromeos/file_manager/volume_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ void VolumeManager::Initialize() {
disk_mount_manager_->AddObserver(this);
disk_mount_manager_->EnsureMountInfoRefreshed(
base::Bind(&VolumeManager::OnDiskMountManagerRefreshed,
weak_ptr_factory_.GetWeakPtr()));
weak_ptr_factory_.GetWeakPtr()),
false /* force */);

// Subscribe to FileSystemProviderService and register currently mounted
// volumes for the profile.
Expand Down
5 changes: 3 additions & 2 deletions chromeos/disks/disk_mount_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@ class DiskMountManagerImpl : public DiskMountManager {

// DiskMountManager override.
void EnsureMountInfoRefreshed(
const EnsureMountInfoRefreshedCallback& callback) override {
if (already_refreshed_) {
const EnsureMountInfoRefreshedCallback& callback,
bool force) override {
if (!force && already_refreshed_) {
callback.Run(true);
return;
}
Expand Down
5 changes: 3 additions & 2 deletions chromeos/disks/disk_mount_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,10 @@ class CHROMEOS_EXPORT DiskMountManager {

// Refreshes all the information about mounting if it is not yet done and
// invokes |callback| when finished. If the information is already refreshed
// It just runs |callback| immediately.
// and |force| is false, it just runs |callback| immediately.
virtual void EnsureMountInfoRefreshed(
const EnsureMountInfoRefreshedCallback& callback) = 0;
const EnsureMountInfoRefreshedCallback& callback,
bool force) = 0;

// Mounts a device.
// Note that the mount operation may fail. To find out the result, one should
Expand Down
8 changes: 4 additions & 4 deletions chromeos/disks/mock_disk_mount_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ MockDiskMountManager::MockDiskMountManager() {
ON_CALL(*this, FindDiskBySourcePath(_))
.WillByDefault(Invoke(
this, &MockDiskMountManager::FindDiskBySourcePathInternal));
ON_CALL(*this, EnsureMountInfoRefreshed(_))
ON_CALL(*this, EnsureMountInfoRefreshed(_, _))
.WillByDefault(Invoke(
this, &MockDiskMountManager::EnsureMountInfoRefreshedInternal));
}
Expand Down Expand Up @@ -168,8 +168,7 @@ void MockDiskMountManager::SetupDefaultReplies() {
.WillRepeatedly(ReturnRef(mount_points_));
EXPECT_CALL(*this, FindDiskBySourcePath(_))
.Times(AnyNumber());
EXPECT_CALL(*this, EnsureMountInfoRefreshed(_))
.Times(AnyNumber());
EXPECT_CALL(*this, EnsureMountInfoRefreshed(_, _)).Times(AnyNumber());
EXPECT_CALL(*this, MountPath(_, _, _, _))
.Times(AnyNumber());
EXPECT_CALL(*this, UnmountPath(_, _, _))
Expand Down Expand Up @@ -243,7 +242,8 @@ MockDiskMountManager::FindDiskBySourcePathInternal(
}

void MockDiskMountManager::EnsureMountInfoRefreshedInternal(
const EnsureMountInfoRefreshedCallback& callback) {
const EnsureMountInfoRefreshedCallback& callback,
bool force) {
callback.Run(true);
}

Expand Down
7 changes: 4 additions & 3 deletions chromeos/disks/mock_disk_mount_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class MockDiskMountManager : public DiskMountManager {
const DiskMountManager::Disk*(const std::string&));
MOCK_CONST_METHOD0(mount_points,
const DiskMountManager::MountPointMap&(void));
MOCK_METHOD1(EnsureMountInfoRefreshed,
void(const EnsureMountInfoRefreshedCallback&));
MOCK_METHOD2(EnsureMountInfoRefreshed,
void(const EnsureMountInfoRefreshedCallback&, bool));
MOCK_METHOD4(MountPath, void(const std::string&, const std::string&,
const std::string&, MountType));
MOCK_METHOD3(UnmountPath, void(const std::string&,
Expand Down Expand Up @@ -92,7 +92,8 @@ class MockDiskMountManager : public DiskMountManager {

// Is used to implement EnsureMountInfoRefreshed.
void EnsureMountInfoRefreshedInternal(
const EnsureMountInfoRefreshedCallback& callback);
const EnsureMountInfoRefreshedCallback& callback,
bool force);

// Notifies observers about device status update.
void NotifyDeviceChanged(DeviceEvent event,
Expand Down
9 changes: 8 additions & 1 deletion chromeos/disks/suspend_unmount_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

namespace chromeos {
namespace disks {
namespace {

void OnRefreshCompleted(bool success) {}

} // namespace

SuspendUnmountManager::SuspendUnmountManager(
DiskMountManager* disk_mount_manager,
Expand Down Expand Up @@ -54,6 +59,8 @@ void SuspendUnmountManager::SuspendDone(const base::TimeDelta& sleep_duration) {
// SuspendDone can be called before OnUnmountComplete when suspend is
// cancelled, or it takes long time to unmount volumes.
unmounting_paths_.clear();
disk_mount_manager_->EnsureMountInfoRefreshed(base::Bind(&OnRefreshCompleted),
true /* force */);
suspend_readiness_callback_.Reset();
}

Expand All @@ -68,5 +75,5 @@ void SuspendUnmountManager::OnUnmountComplete(const std::string& mount_path,
}
}

} // namespace chromeos
} // namespace disks
} // namespace chromeos

0 comments on commit a4b675d

Please sign in to comment.