| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_BROWSER_NOTIFICATION_OBSERVERS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_BROWSER_NOTIFICATION_OBSERVERS_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_BROWSER_NOTIFICATION_OBSERVERS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_BROWSER_NOTIFICATION_OBSERVERS_H_ |
| 7 | 7 |
| 8 #include "base/atomic_sequence_num.h" | 8 #include "base/atomic_sequence_num.h" |
| 9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
| 10 #include "base/time.h" |
| 10 #include "chrome/common/notification_observer.h" | 11 #include "chrome/common/notification_observer.h" |
| 11 #include "chrome/common/notification_registrar.h" | 12 #include "chrome/common/notification_registrar.h" |
| 12 #include "chrome/common/notification_source.h" | 13 #include "chrome/common/notification_source.h" |
| 13 #include "chrome/common/notification_type.h" | 14 #include "chrome/common/notification_type.h" |
| 14 | 15 |
| 15 // Global notification observers for chrome os. | 16 // Global notification observers for chrome os. |
| 16 namespace chromeos { | 17 namespace chromeos { |
| 17 | 18 |
| 18 // Notification observer to log the initial time of when the first tab | 19 // Notification observer to log the initial time of when the first tab |
| 19 // page is rendered for Chrome OS. | 20 // page is rendered for Chrome OS. |
| 20 class InitialTabNotificationObserver : public NotificationObserver { | 21 class InitialTabNotificationObserver : public NotificationObserver { |
| 21 public: | 22 public: |
| 22 InitialTabNotificationObserver(); | 23 InitialTabNotificationObserver(); |
| 23 virtual ~InitialTabNotificationObserver(); | 24 virtual ~InitialTabNotificationObserver(); |
| 24 | 25 |
| 25 static InitialTabNotificationObserver* Get() { | 26 static InitialTabNotificationObserver* Get() { |
| 26 return Singleton<InitialTabNotificationObserver>::get(); | 27 return Singleton<InitialTabNotificationObserver>::get(); |
| 27 } | 28 } |
| 28 | 29 |
| 30 void SetLoginSuccessTime() { |
| 31 login_success_time_ = base::Time::NowFromSystemTime(); |
| 32 } |
| 33 |
| 29 // NotificationObserver implementation. | 34 // NotificationObserver implementation. |
| 30 virtual void Observe(NotificationType type, | 35 virtual void Observe(NotificationType type, |
| 31 const NotificationSource& source, | 36 const NotificationSource& source, |
| 32 const NotificationDetails& details); | 37 const NotificationDetails& details); |
| 33 | 38 |
| 34 private: | 39 private: |
| 35 NotificationRegistrar registrar_; | 40 NotificationRegistrar registrar_; |
| 36 base::AtomicSequenceNumber num_tabs_; | 41 base::AtomicSequenceNumber num_tabs_; |
| 42 base::Time login_success_time_; |
| 37 | 43 |
| 38 DISALLOW_COPY_AND_ASSIGN(InitialTabNotificationObserver); | 44 DISALLOW_COPY_AND_ASSIGN(InitialTabNotificationObserver); |
| 39 }; | 45 }; |
| 40 | 46 |
| 41 // Collects LOGIN_AUTHENTICATION notifications and logs uptime | 47 // Collects LOGIN_AUTHENTICATION notifications and logs uptime |
| 42 // when login was successful. | 48 // when login was successful. |
| 43 class LogLoginSuccessObserver : public NotificationObserver { | 49 class LogLoginSuccessObserver : public NotificationObserver { |
| 44 public: | 50 public: |
| 45 LogLoginSuccessObserver(); | 51 LogLoginSuccessObserver(); |
| 46 virtual ~LogLoginSuccessObserver(); | 52 virtual ~LogLoginSuccessObserver(); |
| 47 | 53 |
| 48 static LogLoginSuccessObserver* Get() { | 54 static LogLoginSuccessObserver* Get() { |
| 49 return Singleton<LogLoginSuccessObserver>::get(); | 55 return Singleton<LogLoginSuccessObserver>::get(); |
| 50 } | 56 } |
| 51 | 57 |
| 52 // NotificationObserver interface. | 58 // NotificationObserver interface. |
| 53 virtual void Observe(NotificationType type, const NotificationSource& source, | 59 virtual void Observe(NotificationType type, const NotificationSource& source, |
| 54 const NotificationDetails& details); | 60 const NotificationDetails& details); |
| 55 | 61 |
| 56 private: | 62 private: |
| 57 NotificationRegistrar registrar_; | 63 NotificationRegistrar registrar_; |
| 58 | 64 |
| 59 DISALLOW_COPY_AND_ASSIGN(LogLoginSuccessObserver); | 65 DISALLOW_COPY_AND_ASSIGN(LogLoginSuccessObserver); |
| 60 }; | 66 }; |
| 61 | 67 |
| 62 } // namespace chromeos | 68 } // namespace chromeos |
| 63 | 69 |
| 64 #endif // CHROME_BROWSER_CHROMEOS_BROWSER_NOTIFICATION_OBSERVERS_H_ | 70 #endif // CHROME_BROWSER_CHROMEOS_BROWSER_NOTIFICATION_OBSERVERS_H_ |
| OLD | NEW |