summaryrefslogtreecommitdiffstats
path: root/chromeos/login_event_recorder.h
blob: f4d0f8b072916217e089901a3dc78b4d4f649d8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_LOGIN_EVENT_RECORDER_H_
#define CHROMEOS_LOGIN_EVENT_RECORDER_H_

#include <string>

#include "base/macros.h"
#include "chromeos/chromeos_export.h"

namespace chromeos {

// LoginEventRecorder records the bootimes of Chrome OS.
// Actual implementation is handled by delegate.
class CHROMEOS_EXPORT LoginEventRecorder {
 public:
  class Delegate {
   public:
  // Add a time marker for login. A timeline will be dumped to
  // /tmp/login-times-sent after login is done. If |send_to_uma| is true
  // the time between this marker and the last will be sent to UMA with
  // the identifier BootTime.|marker_name|.
    virtual void AddLoginTimeMarker(const std::string& marker_name,
                                    bool send_to_uma) = 0;

  // Record events for successful authentication.
    virtual void RecordAuthenticationSuccess() = 0;

  // Record events for authentication failure.
    virtual void RecordAuthenticationFailure() = 0;
  };
  LoginEventRecorder();
  virtual ~LoginEventRecorder();

  static LoginEventRecorder* Get();

  void SetDelegate(Delegate* delegate);

  // Add a time marker for login. A timeline will be dumped to
  // /tmp/login-times-sent after login is done. If |send_to_uma| is true
  // the time between this marker and the last will be sent to UMA with
  // the identifier BootTime.|marker_name|.
  void AddLoginTimeMarker(const std::string& marker_name, bool send_to_uma);

  // Record events for successful authentication.
  void RecordAuthenticationSuccess();

  // Record events for authentication failure.
  void RecordAuthenticationFailure();

 private:
  Delegate* delegate_;

  DISALLOW_COPY_AND_ASSIGN(LoginEventRecorder);
};

}  // namespace chromeos

#endif  // CHROMEOS_LOGIN_EVENT_RECORDER_H_