Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: chrome/browser/chromeos/file_manager/fake_disk_mount_manager.cc

Issue 2348813002: Fix a bug that unmounting devices on the policy update can be a busy loop. (Closed)
Patch Set: Format fix, use reference where copy isn't needed. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/file_manager/fake_disk_mount_manager.h" 5 #include "chrome/browser/chromeos/file_manager/fake_disk_mount_manager.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 8
9 namespace file_manager { 9 namespace file_manager {
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 MountPointMap::iterator iter = mount_points_.find(mount_path); 99 MountPointMap::iterator iter = mount_points_.find(mount_path);
100 if (iter == mount_points_.end()) 100 if (iter == mount_points_.end())
101 return; 101 return;
102 const MountPointInfo mount_point = iter->second; 102 const MountPointInfo mount_point = iter->second;
103 mount_points_.erase(iter); 103 mount_points_.erase(iter);
104 FOR_EACH_OBSERVER(DiskMountManager::Observer, observers_, 104 FOR_EACH_OBSERVER(DiskMountManager::Observer, observers_,
105 OnMountEvent(DiskMountManager::UNMOUNTING, 105 OnMountEvent(DiskMountManager::UNMOUNTING,
106 chromeos::MOUNT_ERROR_NONE, 106 chromeos::MOUNT_ERROR_NONE,
107 mount_point)); 107 mount_point));
108 // Currently |callback| is just ignored. 108 // Enqueue callback so that |FakeDiskMountManager::FinishAllUnmountRequest()|
109 // can call them.
110 pending_unmount_callbacks_.push(callback);
111 }
112
113 bool FakeDiskMountManager::FinishAllUnmountPathRequests() {
114 if (pending_unmount_callbacks_.empty())
115 return false;
116 while (!pending_unmount_callbacks_.empty()) {
117 pending_unmount_callbacks_.front().Run(chromeos::MOUNT_ERROR_NONE);
118 pending_unmount_callbacks_.pop();
119 }
120 return true;
109 } 121 }
110 122
111 void FakeDiskMountManager::FormatMountedDevice(const std::string& mount_path) { 123 void FakeDiskMountManager::FormatMountedDevice(const std::string& mount_path) {
112 } 124 }
113 125
114 void FakeDiskMountManager::UnmountDeviceRecursively( 126 void FakeDiskMountManager::UnmountDeviceRecursively(
115 const std::string& device_path, 127 const std::string& device_path,
116 const UnmountDeviceRecursivelyCallbackType& callback) { 128 const UnmountDeviceRecursivelyCallbackType& callback) {
117 } 129 }
118 130
119 bool FakeDiskMountManager::AddDiskForTest(std::unique_ptr<Disk> disk) { 131 bool FakeDiskMountManager::AddDiskForTest(std::unique_ptr<Disk> disk) {
120 DCHECK(disk); 132 DCHECK(disk);
121 return disks_.insert(make_pair(disk->device_path(), std::move(disk))).second; 133 return disks_.insert(make_pair(disk->device_path(), std::move(disk))).second;
122 } 134 }
123 135
124 bool FakeDiskMountManager::AddMountPointForTest( 136 bool FakeDiskMountManager::AddMountPointForTest(
125 const MountPointInfo& mount_point) { 137 const MountPointInfo& mount_point) {
126 return false; 138 return false;
127 } 139 }
128 140
129 void FakeDiskMountManager::InvokeDiskEventForTest( 141 void FakeDiskMountManager::InvokeDiskEventForTest(
130 chromeos::disks::DiskMountManager::DiskEvent event, 142 chromeos::disks::DiskMountManager::DiskEvent event,
131 const chromeos::disks::DiskMountManager::Disk* disk) { 143 const chromeos::disks::DiskMountManager::Disk* disk) {
132 FOR_EACH_OBSERVER(chromeos::disks::DiskMountManager::Observer, 144 FOR_EACH_OBSERVER(chromeos::disks::DiskMountManager::Observer,
133 observers_, 145 observers_,
134 OnDiskEvent(event, disk)); 146 OnDiskEvent(event, disk));
135 } 147 }
136 148
137 } // namespace file_manager 149 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698