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"
17 class PerformanceTracker
;
18 } // namespace protocol
20 // ClientStatusLogger sends client log entries to a server.
21 // The contents of the log entries are described in server_log_entry_client.cc.
22 // They do not contain any personally identifiable information.
23 class ClientStatusLogger
: public base::NonThreadSafe
{
25 ClientStatusLogger(ServerLogEntry::Mode mode
,
26 SignalStrategy
* signal_strategy
,
27 const std::string
& directory_bot_jid
);
28 ~ClientStatusLogger();
30 void LogSessionStateChange(protocol::ConnectionToHost::State state
,
31 protocol::ErrorCode error
);
32 void LogStatistics(protocol::PerformanceTracker
* perf_tracker
);
34 // Allows test code to fake SignalStrategy state change events.
35 void SetSignalingStateForTest(SignalStrategy::State state
);
38 LogToServer log_to_server_
;
40 // Generates a new random session ID.
41 void GenerateSessionId();
43 // Expire the session ID if the maximum duration has been exceeded.
44 void MaybeExpireSessionId();
46 // A randomly generated session ID to be attached to log messages. This
47 // is regenerated at the start of a new session.
48 std::string session_id_
;
50 // Start time of the session.
51 base::TimeTicks session_start_time_
;
53 // Time when the session ID was generated.
54 base::TimeTicks session_id_generation_time_
;
56 DISALLOW_COPY_AND_ASSIGN(ClientStatusLogger
);
59 } // namespace remoting
61 #endif // REMOTING_CLIENT_CLIENT_STATUS_LOGGER_H_