Home | History | Annotate | Download | only in chromeos
      1 // Copyright 2014 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_LOGIN_EVENT_RECORDER_H_
      6 #define CHROMEOS_LOGIN_EVENT_RECORDER_H_
      7 
      8 #include <string>
      9 
     10 #include "base/macros.h"
     11 #include "chromeos/chromeos_export.h"
     12 
     13 namespace chromeos {
     14 
     15 // LoginEventRecorder records the bootimes of Chrome OS.
     16 // Actual implementation is handled by delegate.
     17 class CHROMEOS_EXPORT LoginEventRecorder {
     18  public:
     19   class Delegate {
     20    public:
     21   // Add a time marker for login. A timeline will be dumped to
     22   // /tmp/login-times-sent after login is done. If |send_to_uma| is true
     23   // the time between this marker and the last will be sent to UMA with
     24   // the identifier BootTime.|marker_name|.
     25     virtual void AddLoginTimeMarker(const std::string& marker_name,
     26                                     bool send_to_uma) = 0;
     27 
     28   // Record events for successful authentication.
     29     virtual void RecordAuthenticationSuccess() = 0;
     30 
     31   // Record events for authentication failure.
     32     virtual void RecordAuthenticationFailure() = 0;
     33   };
     34   LoginEventRecorder();
     35   virtual ~LoginEventRecorder();
     36 
     37   static LoginEventRecorder* Get();
     38 
     39   void SetDelegate(Delegate* delegate);
     40 
     41   // 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
     43   // the time between this marker and the last will be sent to UMA with
     44   // the identifier BootTime.|marker_name|.
     45   void AddLoginTimeMarker(const std::string& marker_name, bool send_to_uma);
     46 
     47   // Record events for successful authentication.
     48   void RecordAuthenticationSuccess();
     49 
     50   // Record events for authentication failure.
     51   void RecordAuthenticationFailure();
     52 
     53  private:
     54   Delegate* delegate_;
     55 
     56   DISALLOW_COPY_AND_ASSIGN(LoginEventRecorder);
     57 };
     58 
     59 }  // namespace chromeos
     60 
     61 #endif  // CHROMEOS_LOGIN_EVENT_RECORDER_H_
     62