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

Side by Side Diff: chrome/browser/chromeos/ui/low_disk_notification.h

Issue 2082363004: Show notifications on low disk space. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@low-disk-strings
Patch Set: Modified throttling to limit MEDIUM notifications to once per session Created 4 years, 5 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 2016 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_UI_LOW_DISK_NOTIFICATION_H_
6 #define CHROME_BROWSER_CHROMEOS_UI_LOW_DISK_NOTIFICATION_H_
7
8 #include <stdint.h>
9
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/time/time.h"
13
14 namespace message_center {
15 class Notification;
16 class MessageCenter;
17 }
18
19 namespace chromeos {
20
21 // LowDiskNotification manages the notification informing the user of low disk
22 // space. It is responsible for both creating the notifications in message
23 // center as well as throttling notifications shown to the user.
24 // This class should be created after DBus has been initialized and destroyed
25 // before DBus has been shutdown.
26 class LowDiskNotification {
27 public:
28 // Registers this class as the CryptohomeClient LowDiskSpaceHandler.
29 LowDiskNotification();
30 // Resets CryptohomeClient LowDiskSpaceHandler.
31 ~LowDiskNotification();
32
33 // Called when the device is running low on disk space. This is responsible
34 // for deciding whether a notification should be shown or not and showing it
35 // if appropriate.
36 void OnLowDiskSpace(uint64_t free_disk_bytes);
37
38 private:
39 friend class LowDiskNotificationTest;
40
41 enum Severity { NONE = -1, MEDIUM = 0, HIGH = 1 };
42
43 // Creates a notification for the specified severity. If the severity does
44 // not match a known value MEDIUM is used by default.
45 std::unique_ptr<message_center::Notification> CreateNotification(
46 Severity severity);
satorux1 2016/06/28 05:53:27 nit: adds a blank line between functions?
dspaid 2016/06/28 06:29:53 Done.
47 // Gets the severity of the low disk status based on the amount of free space
48 // left on the disk.
49 Severity GetSeverity(uint64_t free_disk_bytes);
50 // Sets the MessageCenter instance to use. Should only be used in tests.
51 void SetMessageCenterForTest(message_center::MessageCenter* message_center);
52 // Sets the minimum time to wait between notifications of the same severity.
53 // Should only be used in tests.
54 void SetNotificationIntervalForTest(base::TimeDelta interval);
55
56 base::Time last_notification_time_;
57 Severity last_notification_severity_;
58 message_center::MessageCenter* message_center_;
59 base::TimeDelta notification_interval_;
60 base::WeakPtrFactory<LowDiskNotification> weak_ptr_factory_;
61
62 DISALLOW_COPY_AND_ASSIGN(LowDiskNotification);
63 };
64
65 } // namespace chromeos
66
67 #endif // CHROME_BROWSER_CHROMEOS_UI_LOW_DISK_NOTIFICATION_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/chrome_browser_main_chromeos.cc ('k') | chrome/browser/chromeos/ui/low_disk_notification.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698