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

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: Eliminate unrelated and unnecessary change. Created 4 years, 3 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 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 9
10 namespace file_manager { 10 namespace file_manager {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 MountPointMap::iterator iter = mount_points_.find(mount_path); 101 MountPointMap::iterator iter = mount_points_.find(mount_path);
102 if (iter == mount_points_.end()) 102 if (iter == mount_points_.end())
103 return; 103 return;
104 const MountPointInfo mount_point = iter->second; 104 const MountPointInfo mount_point = iter->second;
105 mount_points_.erase(iter); 105 mount_points_.erase(iter);
106 FOR_EACH_OBSERVER(DiskMountManager::Observer, observers_, 106 FOR_EACH_OBSERVER(DiskMountManager::Observer, observers_,
107 OnMountEvent(DiskMountManager::UNMOUNTING, 107 OnMountEvent(DiskMountManager::UNMOUNTING,
108 chromeos::MOUNT_ERROR_NONE, 108 chromeos::MOUNT_ERROR_NONE,
109 mount_point)); 109 mount_point));
110 // Currently |callback| is just ignored. 110 // Enqueue callback so that |FakeDiskMountManager::FinishAllUnmountRequest()|
111 // can call them.
112 pending_unmount_callbacks_.push(callback);
fukino 2016/09/16 07:31:34 Why do we need FinishAllUnmountPathRequests() call
yamaguchi 2016/09/16 08:49:51 The main purpose of this change in the test & the
113 }
114
115 bool FakeDiskMountManager::FinishAllUnmountPathRequests() {
116 if (pending_unmount_callbacks_.empty())
117 return false;
118 while (!pending_unmount_callbacks_.empty()) {
119 pending_unmount_callbacks_.front().Run(chromeos::MOUNT_ERROR_NONE);
120 pending_unmount_callbacks_.pop();
121 }
122 return true;
111 } 123 }
112 124
113 void FakeDiskMountManager::FormatMountedDevice(const std::string& mount_path) { 125 void FakeDiskMountManager::FormatMountedDevice(const std::string& mount_path) {
114 } 126 }
115 127
116 void FakeDiskMountManager::UnmountDeviceRecursively( 128 void FakeDiskMountManager::UnmountDeviceRecursively(
117 const std::string& device_path, 129 const std::string& device_path,
118 const UnmountDeviceRecursivelyCallbackType& callback) { 130 const UnmountDeviceRecursivelyCallbackType& callback) {
119 } 131 }
120 132
121 bool FakeDiskMountManager::AddDiskForTest(Disk* disk) { 133 bool FakeDiskMountManager::AddDiskForTest(Disk* disk) {
122 DCHECK(disk); 134 DCHECK(disk);
123 return disks_.insert(make_pair(disk->device_path(), disk)).second; 135 return disks_.insert(make_pair(disk->device_path(), disk)).second;
124 } 136 }
125 137
126 bool FakeDiskMountManager::AddMountPointForTest( 138 bool FakeDiskMountManager::AddMountPointForTest(
127 const MountPointInfo& mount_point) { 139 const MountPointInfo& mount_point) {
128 return false; 140 return false;
129 } 141 }
130 142
131 void FakeDiskMountManager::InvokeDiskEventForTest( 143 void FakeDiskMountManager::InvokeDiskEventForTest(
132 chromeos::disks::DiskMountManager::DiskEvent event, 144 chromeos::disks::DiskMountManager::DiskEvent event,
133 const chromeos::disks::DiskMountManager::Disk* disk) { 145 const chromeos::disks::DiskMountManager::Disk* disk) {
134 FOR_EACH_OBSERVER(chromeos::disks::DiskMountManager::Observer, 146 FOR_EACH_OBSERVER(chromeos::disks::DiskMountManager::Observer,
135 observers_, 147 observers_,
136 OnDiskEvent(event, disk)); 148 OnDiskEvent(event, disk));
137 } 149 }
138 150
139 } // namespace file_manager 151 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698