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 REMOTING_CLIENT_CLIENT_STATUS_LOGGER_H_ 6 #define REMOTING_CLIENT_CLIENT_STATUS_LOGGER_H_ 7 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" 13 14 namespace remoting { 15 16 class ChromotingStats; 17 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(); 27 28 void LogSessionStateChange(protocol::ConnectionToHost::State state, 29 protocol::ErrorCode error); 30 void LogStatistics(remoting::ChromotingStats* statistics); 31 32 // Allows test code to fake SignalStrategy state change events. 33 void SetSignalingStateForTest(SignalStrategy::State state); 34 35 private: 36 LogToServer log_to_server_; 37 38 // Generates a new random session ID. 39 void GenerateSessionId(); 40 41 // Expire the session ID if the maximum duration has been exceeded. 42 void MaybeExpireSessionId(); 43 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_; 47 48 // Start time of the session. 49 base::TimeTicks session_start_time_; 50 51 // Time when the session ID was generated. 52 base::TimeTicks session_id_generation_time_; 53 54 DISALLOW_COPY_AND_ASSIGN(ClientStatusLogger); 55 }; 56 57 } // namespace remoting 58 59 #endif // REMOTING_CLIENT_CLIENT_STATUS_LOGGER_H_ 60