Convert AddUserStory to AddStory for perf/
[chromium-blink-merge.git] / remoting / client / client_status_logger.h
blobafc64b92a8163e407c5d63459042158015a59277
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.
5 #ifndef REMOTING_CLIENT_CLIENT_STATUS_LOGGER_H_
6 #define REMOTING_CLIENT_CLIENT_STATUS_LOGGER_H_
8 #include "base/threading/non_thread_safe.h"
9 #include "base/time/time.h"
10 #include "remoting/protocol/connection_to_host.h"
11 #include "remoting/protocol/errors.h"
12 #include "remoting/signaling/log_to_server.h"
14 namespace remoting {
16 class ChromotingStats;
18 // ClientStatusLogger sends client log entries to a server.
19 // The contents of the log entries are described in server_log_entry_client.cc.
20 // They do not contain any personally identifiable information.
21 class ClientStatusLogger : public base::NonThreadSafe {
22 public:
23 ClientStatusLogger(ServerLogEntry::Mode mode,
24 SignalStrategy* signal_strategy,
25 const std::string& directory_bot_jid);
26 ~ClientStatusLogger();
28 void LogSessionStateChange(protocol::ConnectionToHost::State state,
29 protocol::ErrorCode error);
30 void LogStatistics(remoting::ChromotingStats* statistics);
32 // Allows test code to fake SignalStrategy state change events.
33 void SetSignalingStateForTest(SignalStrategy::State state);
35 private:
36 LogToServer log_to_server_;
38 // Generates a new random session ID.
39 void GenerateSessionId();
41 // Expire the session ID if the maximum duration has been exceeded.
42 void MaybeExpireSessionId();
44 // A randomly generated session ID to be attached to log messages. This
45 // is regenerated at the start of a new session.
46 std::string session_id_;
48 // Start time of the session.
49 base::TimeTicks session_start_time_;
51 // Time when the session ID was generated.
52 base::TimeTicks session_id_generation_time_;
54 DISALLOW_COPY_AND_ASSIGN(ClientStatusLogger);
57 } // namespace remoting
59 #endif // REMOTING_CLIENT_CLIENT_STATUS_LOGGER_H_