| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BOOT_TIMES_LOADER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_BOOT_TIMES_LOADER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_BOOT_TIMES_LOADER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_BOOT_TIMES_LOADER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/atomic_sequence_num.h" | 11 #include "base/atomic_sequence_num.h" |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/task/cancelable_task_tracker.h" | 14 #include "base/task/cancelable_task_tracker.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "chromeos/login_event_recorder.h" |
| 16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 18 #include "content/public/browser/render_widget_host.h" | 19 #include "content/public/browser/render_widget_host.h" |
| 19 | 20 |
| 20 class PrefService; | 21 class PrefService; |
| 21 | 22 |
| 22 namespace chromeos { | 23 namespace chromeos { |
| 23 | 24 |
| 24 // BootTimesLoader loads the bootimes of Chrome OS from the file system. | 25 // BootTimesLoader loads the bootimes of Chrome OS from the file system. |
| 25 // Loading is done asynchronously on the file thread. Once loaded, | 26 // Loading is done asynchronously on the file thread. Once loaded, |
| 26 // BootTimesLoader calls back to a method of your choice with the boot times. | 27 // BootTimesLoader calls back to a method of your choice with the boot times. |
| 27 // To use BootTimesLoader, do the following: | 28 // To use BootTimesLoader, do the following: |
| 28 // | 29 // |
| 29 // . In your class define a member field of type chromeos::BootTimesLoader and | 30 // . In your class define a member field of type chromeos::BootTimesLoader and |
| 30 // base::CancelableTaskTracker. | 31 // base::CancelableTaskTracker. |
| 31 // . Define the callback method, something like: | 32 // . Define the callback method, something like: |
| 32 // void OnBootTimesLoaded(const BootTimesLoader::BootTimes& boot_times); | 33 // void OnBootTimesLoaded(const BootTimesLoader::BootTimes& boot_times); |
| 33 // . When you want the version invoke: loader.GetBootTimes(callback, &tracker_); | 34 // . When you want the version invoke: loader.GetBootTimes(callback, &tracker_); |
| 34 class BootTimesLoader : public content::NotificationObserver { | 35 class BootTimesLoader : public content::NotificationObserver, |
| 36 public LoginEventRecorder::Delegate { |
| 35 public: | 37 public: |
| 36 BootTimesLoader(); | 38 BootTimesLoader(); |
| 37 virtual ~BootTimesLoader(); | 39 virtual ~BootTimesLoader(); |
| 38 | 40 |
| 39 static BootTimesLoader* Get(); | 41 static BootTimesLoader* Get(); |
| 40 | 42 |
| 43 // LoginEventRecorder::Delegate override. |
| 44 |
| 41 // Add a time marker for login. A timeline will be dumped to | 45 // Add a time marker for login. A timeline will be dumped to |
| 42 // /tmp/login-times-sent after login is done. If |send_to_uma| is true | 46 // /tmp/login-times-sent after login is done. If |send_to_uma| is true |
| 43 // the time between this marker and the last will be sent to UMA with | 47 // the time between this marker and the last will be sent to UMA with |
| 44 // the identifier BootTime.|marker_name|. | 48 // the identifier BootTime.|marker_name|. |
| 45 void AddLoginTimeMarker(const std::string& marker_name, bool send_to_uma); | 49 virtual void AddLoginTimeMarker(const std::string& marker_name, |
| 50 bool send_to_uma) OVERRIDE; |
| 46 | 51 |
| 47 // Add a time marker for logout. A timeline will be dumped to | 52 // Add a time marker for logout. A timeline will be dumped to |
| 48 // /tmp/logout-times-sent after logout is done. If |send_to_uma| is true | 53 // /tmp/logout-times-sent after logout is done. If |send_to_uma| is true |
| 49 // the time between this marker and the last will be sent to UMA with | 54 // the time between this marker and the last will be sent to UMA with |
| 50 // the identifier ShutdownTime.|marker_name|. | 55 // the identifier ShutdownTime.|marker_name|. |
| 51 void AddLogoutTimeMarker(const std::string& marker_name, bool send_to_uma); | 56 void AddLogoutTimeMarker(const std::string& marker_name, bool send_to_uma); |
| 52 | 57 |
| 53 // Records current uptime and disk usage for metrics use. | 58 // Records current uptime and disk usage for metrics use. |
| 54 // Posts task to file thread. | 59 // Posts task to file thread. |
| 55 // name will be used as part of file names in /tmp. | 60 // name will be used as part of file names in /tmp. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 bool login_done_; | 188 bool login_done_; |
| 184 | 189 |
| 185 bool restart_requested_; | 190 bool restart_requested_; |
| 186 | 191 |
| 187 DISALLOW_COPY_AND_ASSIGN(BootTimesLoader); | 192 DISALLOW_COPY_AND_ASSIGN(BootTimesLoader); |
| 188 }; | 193 }; |
| 189 | 194 |
| 190 } // namespace chromeos | 195 } // namespace chromeos |
| 191 | 196 |
| 192 #endif // CHROME_BROWSER_CHROMEOS_BOOT_TIMES_LOADER_H_ | 197 #endif // CHROME_BROWSER_CHROMEOS_BOOT_TIMES_LOADER_H_ |
| OLD | NEW |