blob: b52687c7d35c6edcd45286b2f5595109e0762f0a [file] [log] [blame]
hirono9f5eae542015-06-22 04:28:411// Copyright 2015 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 CHROMEOS_DISKS_SUSPEND_UNMOUNT_MANAGER_H_
6#define CHROMEOS_DISKS_SUSPEND_UNMOUNT_MANAGER_H_
7
8#include <set>
9#include <string>
10
11#include "chromeos/chromeos_export.h"
12#include "chromeos/dbus/cros_disks_client.h"
13#include "chromeos/dbus/power_manager_client.h"
14
15namespace chromeos {
16namespace disks {
17
18class DiskMountManager;
19
20// Class to unmount disks at suspend.
21class CHROMEOS_EXPORT SuspendUnmountManager
22 : public PowerManagerClient::Observer {
23 public:
24 // The ownership of these raw pointers still remains with the caller.
25 SuspendUnmountManager(DiskMountManager* disk_mount_manager,
26 PowerManagerClient* power_manager_client);
27 ~SuspendUnmountManager() override;
28
29 private:
30 void OnUnmountComplete(const std::string& mount_path,
31 chromeos::MountError error_code);
32
33 // PowerManagerClient::Observer
34 void SuspendImminent() override;
35 void SuspendDone(const base::TimeDelta& sleep_duration) override;
36
37 // Callback passed to DiskMountManager holds weak pointers of this.
38 DiskMountManager* const disk_mount_manager_;
39 PowerManagerClient* const power_manager_client_;
40
41 // The paths that the manager currently tries to unmount for suspend.
42 std::set<std::string> unmounting_paths_;
43
44 base::Closure suspend_readiness_callback_;
45
46 base::WeakPtrFactory<SuspendUnmountManager> weak_ptr_factory_;
47
48 DISALLOW_COPY_AND_ASSIGN(SuspendUnmountManager);
49};
50
51} // namespace disks
52} // namespace chromeos
53
54#endif // CHROMEOS_DISKS_SUSPEND_UNMOUNT_MANAGER_H_