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

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

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
« no previous file with comments | « no previous file | chrome/browser/chromeos/file_manager/fake_disk_mount_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FAKE_DISK_MOUNT_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FAKE_DISK_MOUNT_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FAKE_DISK_MOUNT_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FAKE_DISK_MOUNT_MANAGER_H_
7 7
8 #include <queue>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/observer_list.h" 14 #include "base/observer_list.h"
14 #include "chromeos/dbus/cros_disks_client.h" 15 #include "chromeos/dbus/cros_disks_client.h"
15 #include "chromeos/disks/disk_mount_manager.h" 16 #include "chromeos/disks/disk_mount_manager.h"
16 17
17 namespace file_manager { 18 namespace file_manager {
(...skipping 26 matching lines...) Expand all
44 FakeDiskMountManager(); 45 FakeDiskMountManager();
45 ~FakeDiskMountManager() override; 46 ~FakeDiskMountManager() override;
46 47
47 const std::vector<MountRequest>& mount_requests() const { 48 const std::vector<MountRequest>& mount_requests() const {
48 return mount_requests_; 49 return mount_requests_;
49 } 50 }
50 const std::vector<UnmountRequest>& unmount_requests() const { 51 const std::vector<UnmountRequest>& unmount_requests() const {
51 return unmount_requests_; 52 return unmount_requests_;
52 } 53 }
53 54
55 // Emulates that all mount request finished.
56 // Return true if there was one or more mount request enqueued, or false
57 // otherwise.
58 bool FinishAllUnmountPathRequests();
59
54 // DiskMountManager overrides. 60 // DiskMountManager overrides.
55 void AddObserver(Observer* observer) override; 61 void AddObserver(Observer* observer) override;
56 void RemoveObserver(Observer* observer) override; 62 void RemoveObserver(Observer* observer) override;
57 const DiskMap& disks() const override; 63 const DiskMap& disks() const override;
58 const Disk* FindDiskBySourcePath( 64 const Disk* FindDiskBySourcePath(
59 const std::string& source_path) const override; 65 const std::string& source_path) const override;
60 const MountPointMap& mount_points() const override; 66 const MountPointMap& mount_points() const override;
61 void EnsureMountInfoRefreshed( 67 void EnsureMountInfoRefreshed(
62 const EnsureMountInfoRefreshedCallback& callback, 68 const EnsureMountInfoRefreshedCallback& callback,
63 bool force) override; 69 bool force) override;
64 void MountPath(const std::string& source_path, 70 void MountPath(const std::string& source_path,
65 const std::string& source_format, 71 const std::string& source_format,
66 const std::string& mount_label, 72 const std::string& mount_label,
67 chromeos::MountType type, 73 chromeos::MountType type,
68 chromeos::MountAccessMode access_mode) override; 74 chromeos::MountAccessMode access_mode) override;
75 // In order to simulate asynchronous invocation of callbacks after unmount
76 // is finished, |callback| will be invoked only when
77 // |FinishAllUnmountRequest()| is called.
69 void UnmountPath(const std::string& mount_path, 78 void UnmountPath(const std::string& mount_path,
70 chromeos::UnmountOptions options, 79 chromeos::UnmountOptions options,
71 const UnmountPathCallback& callback) override; 80 const UnmountPathCallback& callback) override;
72 void FormatMountedDevice(const std::string& mount_path) override; 81 void FormatMountedDevice(const std::string& mount_path) override;
73 void UnmountDeviceRecursively( 82 void UnmountDeviceRecursively(
74 const std::string& device_path, 83 const std::string& device_path,
75 const UnmountDeviceRecursivelyCallbackType& callback) override; 84 const UnmountDeviceRecursivelyCallbackType& callback) override;
76 85
77 bool AddDiskForTest(std::unique_ptr<Disk> disk) override; 86 bool AddDiskForTest(std::unique_ptr<Disk> disk) override;
78 bool AddMountPointForTest(const MountPointInfo& mount_point) override; 87 bool AddMountPointForTest(const MountPointInfo& mount_point) override;
79 void InvokeDiskEventForTest(DiskEvent event, const Disk* disk); 88 void InvokeDiskEventForTest(DiskEvent event, const Disk* disk);
80 89
81 private: 90 private:
82 base::ObserverList<Observer> observers_; 91 base::ObserverList<Observer> observers_;
92 std::queue<UnmountPathCallback> pending_unmount_callbacks_;
Lei Zhang 2016/09/27 17:21:02 With this, we can no longer depend on base/callbac
83 93
84 DiskMap disks_; 94 DiskMap disks_;
85 MountPointMap mount_points_; 95 MountPointMap mount_points_;
86 96
87 std::vector<MountRequest> mount_requests_; 97 std::vector<MountRequest> mount_requests_;
88 std::vector<UnmountRequest> unmount_requests_; 98 std::vector<UnmountRequest> unmount_requests_;
89 99
90 DISALLOW_COPY_AND_ASSIGN(FakeDiskMountManager); 100 DISALLOW_COPY_AND_ASSIGN(FakeDiskMountManager);
91 }; 101 };
92 102
93 } // namespace file_manager 103 } // namespace file_manager
94 104
95 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FAKE_DISK_MOUNT_MANAGER_H_ 105 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FAKE_DISK_MOUNT_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/file_manager/fake_disk_mount_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698