OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_CLIENT_LOG_TO_SERVER_H_ | 5 #ifndef REMOTING_CLIENT_LOG_TO_SERVER_H_ |
6 #define REMOTING_CLIENT_LOG_TO_SERVER_H_ | 6 #define REMOTING_CLIENT_LOG_TO_SERVER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "remoting/client/server_log_entry.h" | |
15 #include "remoting/jingle_glue/signal_strategy.h" | 14 #include "remoting/jingle_glue/signal_strategy.h" |
16 #include "remoting/protocol/connection_to_host.h" | 15 #include "remoting/protocol/connection_to_host.h" |
17 #include "remoting/protocol/errors.h" | 16 #include "remoting/protocol/errors.h" |
| 17 #include "remoting/protocol/server_log_entry.h" |
18 | 18 |
19 namespace buzz { | 19 namespace buzz { |
20 class XmlElement; | 20 class XmlElement; |
21 } // namespace buzz | 21 } // namespace buzz |
22 | 22 |
23 namespace remoting { | 23 namespace remoting { |
24 | 24 |
25 class ChromotingStats; | 25 class ChromotingStats; |
26 class IqSender; | 26 class IqSender; |
27 | 27 |
28 // Temporary namespace to prevent conflict with the same-named class in | 28 // Temporary namespace to prevent conflict with the same-named class in |
29 // remoting/host when linking unittests. | 29 // remoting/host when linking unittests. |
30 // | 30 // |
31 // TODO(lambroslambrou): Remove this and factor out any shared code. | 31 // TODO(lambroslambrou): Remove this and factor out any shared code. |
32 namespace client { | 32 namespace client { |
33 | 33 |
34 // LogToServer sends log entries to a server. | 34 // LogToServer sends log entries to a server. |
35 // The contents of the log entries are described in server_log_entry.cc. | 35 // The contents of the log entries are described in server_log_entry.cc. |
36 // They do not contain any personally identifiable information. | 36 // They do not contain any personally identifiable information. |
37 class LogToServer : public base::NonThreadSafe, | 37 class LogToServer : public base::NonThreadSafe, |
38 public SignalStrategy::Listener { | 38 public SignalStrategy::Listener { |
39 public: | 39 public: |
40 LogToServer(ServerLogEntry::Mode mode, | 40 LogToServer(protocol::ServerLogEntry::Mode mode, |
41 SignalStrategy* signal_strategy, | 41 SignalStrategy* signal_strategy, |
42 const std::string& directory_bot_jid); | 42 const std::string& directory_bot_jid); |
43 virtual ~LogToServer(); | 43 virtual ~LogToServer(); |
44 | 44 |
45 // Logs a session state change. | 45 // Logs a session state change. |
46 void LogSessionStateChange(protocol::ConnectionToHost::State state, | 46 void LogSessionStateChange(protocol::ConnectionToHost::State state, |
47 protocol::ErrorCode error); | 47 protocol::ErrorCode error); |
48 void LogStatistics(remoting::ChromotingStats* statistics); | 48 void LogStatistics(remoting::ChromotingStats* statistics); |
49 | 49 |
50 // SignalStrategy::Listener interface. | 50 // SignalStrategy::Listener interface. |
51 virtual void OnSignalStrategyStateChange( | 51 virtual void OnSignalStrategyStateChange( |
52 SignalStrategy::State state) OVERRIDE; | 52 SignalStrategy::State state) OVERRIDE; |
53 virtual bool OnSignalStrategyIncomingStanza( | 53 virtual bool OnSignalStrategyIncomingStanza( |
54 const buzz::XmlElement* stanza) OVERRIDE; | 54 const buzz::XmlElement* stanza) OVERRIDE; |
55 | 55 |
56 private: | 56 private: |
57 void Log(const ServerLogEntry& entry); | 57 void Log(const protocol::ServerLogEntry& entry); |
58 void SendPendingEntries(); | 58 void SendPendingEntries(); |
59 | 59 |
60 // Generates a new random session ID. | 60 // Generates a new random session ID. |
61 void GenerateSessionId(); | 61 void GenerateSessionId(); |
62 | 62 |
63 // Expire the session ID if the maximum duration has been exceeded. | 63 // Expire the session ID if the maximum duration has been exceeded. |
64 void MaybeExpireSessionId(); | 64 void MaybeExpireSessionId(); |
65 | 65 |
66 ServerLogEntry::Mode mode_; | 66 protocol::ServerLogEntry::Mode mode_; |
67 SignalStrategy* signal_strategy_; | 67 SignalStrategy* signal_strategy_; |
68 scoped_ptr<IqSender> iq_sender_; | 68 scoped_ptr<IqSender> iq_sender_; |
69 std::string directory_bot_jid_; | 69 std::string directory_bot_jid_; |
70 | 70 |
71 std::deque<ServerLogEntry> pending_entries_; | 71 std::deque<protocol::ServerLogEntry> pending_entries_; |
72 | 72 |
73 // A randomly generated session ID to be attached to log messages. This | 73 // A randomly generated session ID to be attached to log messages. This |
74 // is regenerated at the start of a new session. | 74 // is regenerated at the start of a new session. |
75 std::string session_id_; | 75 std::string session_id_; |
76 | 76 |
77 // Start time of the session. | 77 // Start time of the session. |
78 base::TimeTicks session_start_time_; | 78 base::TimeTicks session_start_time_; |
79 | 79 |
80 // Time when the session ID was generated. | 80 // Time when the session ID was generated. |
81 base::TimeTicks session_id_generation_time_; | 81 base::TimeTicks session_id_generation_time_; |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(LogToServer); | 83 DISALLOW_COPY_AND_ASSIGN(LogToServer); |
84 }; | 84 }; |
85 | 85 |
86 } // namespace client | 86 } // namespace client |
87 | 87 |
88 } // namespace remoting | 88 } // namespace remoting |
89 | 89 |
90 #endif // REMOTING_CLIENT_LOG_TO_SERVER_H_ | 90 #endif // REMOTING_CLIENT_LOG_TO_SERVER_H_ |
OLD | NEW |