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

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

Issue 479563007: Files.app: Remove MountedDiskMonitor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_MOUNTED_DISK_MONITOR_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_MOUNTED_DISK_MONITOR_H_
7
8 #include <map>
9 #include <set>
10 #include <string>
11
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "chromeos/dbus/power_manager_client.h"
15 #include "chromeos/disks/disk_mount_manager.h"
16
17 namespace file_manager {
18
19 // Observes PowerManager and updates its state when the system suspends and
20 // resumes. After the system resumes it will stay in "is_resuming" state for
21 // couple of seconds. This is to give DiskManager time to process device
22 // removed/added events (events for the devices that were present before suspend
23 // should not trigger any new notifications or file manager windows).
24 class MountedDiskMonitor : public chromeos::PowerManagerClient::Observer {
25 public:
26 explicit MountedDiskMonitor(
27 chromeos::PowerManagerClient* power_manager_client);
28 virtual ~MountedDiskMonitor();
29
30 // PowerManagerClient::Observer overrides:
31 virtual void SuspendImminent() OVERRIDE;
32 virtual void SuspendDone(const base::TimeDelta& sleep_duration) OVERRIDE;
33
34 // Receives forwarded notifications originates from DiskMountManager.
35 void OnDiskEvent(
36 chromeos::disks::DiskMountManager::DiskEvent event,
37 const chromeos::disks::DiskMountManager::Disk* disk);
38 void OnDeviceEvent(
39 chromeos::disks::DiskMountManager::DeviceEvent event,
40 const std::string& device_path);
41 void OnMountEvent(
42 chromeos::disks::DiskMountManager::MountEvent event,
43 chromeos::MountError error_code,
44 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info,
45 const chromeos::disks::DiskMountManager::Disk* disk);
46
47 // Checks if the disk is being remounted. The disk is remounting if it has
48 // been unmounted during the resuming time span.
49 bool DiskIsRemounting(
50 const chromeos::disks::DiskMountManager::Disk& disk) const;
51 bool DeviceIsHardUnpluggedButNotReported(
52 const std::string& device_path) const;
53 void MarkAsHardUnpluggedReported(const std::string& device_path);
54
55 // In order to avoid consuming time a lot for testing, this allows to set the
56 // resuming time span.
57 void set_resuming_time_span_for_testing(
58 const base::TimeDelta& resuming_time_span) {
59 resuming_time_span_ = resuming_time_span;
60 }
61
62 private:
63 enum HardUnpluggedState { HARD_UNPLUGGED, HARD_UNPLUGGED_AND_REPORTED };
64 // Maps source paths with corresponding uuids.
65 typedef std::map<std::string, std::string> DiskMap;
66
67 // Set of uuids.
68 typedef std::set<std::string> DiskSet;
69
70 void Reset();
71
72 chromeos::PowerManagerClient* power_manager_client_;
73
74 bool is_resuming_;
75 DiskMap mounted_disks_;
76 DiskSet unmounted_while_resuming_;
77 // Set of device path that is hard unplugged.
78 std::map<std::string, HardUnpluggedState> hard_unplugged_;
79 base::TimeDelta resuming_time_span_;
80 base::WeakPtrFactory<MountedDiskMonitor> weak_factory_;
81
82 DISALLOW_COPY_AND_ASSIGN(MountedDiskMonitor);
83 };
84
85 } // namespace file_manager
86
87 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_MOUNTED_DISK_MONITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698