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