Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: remoting/jingle_glue/log_to_server.h

Issue 320403002: Pull out common code from client and host versions of LogToServer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unittests for LogToServer Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/remoting_me2me_host.cc ('k') | remoting/jingle_glue/log_to_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_JINGLE_GLUE_LOG_TO_SERVER_H_
6 #define REMOTING_CLIENT_LOG_TO_SERVER_H_ 6 #define REMOTING_JINGLE_GLUE_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"
14 #include "remoting/jingle_glue/server_log_entry.h" 13 #include "remoting/jingle_glue/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"
17 #include "remoting/protocol/errors.h"
18 15
19 namespace buzz { 16 namespace buzz {
20 class XmlElement; 17 class XmlElement;
21 } // namespace buzz 18 } // namespace buzz
22 19
23 namespace remoting { 20 namespace remoting {
24 21
25 class ChromotingStats;
26 class IqSender; 22 class IqSender;
27 23
28 // Temporary namespace to prevent conflict with the same-named class in
29 // remoting/host when linking unittests.
30 //
31 // TODO(lambroslambrou): Remove this and factor out any shared code.
32 namespace client {
33
34 // LogToServer sends log entries to a server. 24 // LogToServer sends log entries to a server.
35 // The contents of the log entries are described in server_log_entry.cc. 25 // The contents of the log entries are described in server_log_entry.cc.
36 // They do not contain any personally identifiable information. 26 // They do not contain any personally identifiable information.
37 class LogToServer : public base::NonThreadSafe, 27 class LogToServer : public base::NonThreadSafe,
38 public SignalStrategy::Listener { 28 public SignalStrategy::Listener {
39 public: 29 public:
40 LogToServer(ServerLogEntry::Mode mode, 30 LogToServer(ServerLogEntry::Mode mode,
41 SignalStrategy* signal_strategy, 31 SignalStrategy* signal_strategy,
42 const std::string& directory_bot_jid); 32 const std::string& directory_bot_jid);
43 virtual ~LogToServer(); 33 virtual ~LogToServer();
44 34
45 // Logs a session state change.
46 void LogSessionStateChange(protocol::ConnectionToHost::State state,
47 protocol::ErrorCode error);
48 void LogStatistics(remoting::ChromotingStats* statistics);
49
50 // SignalStrategy::Listener interface. 35 // SignalStrategy::Listener interface.
51 virtual void OnSignalStrategyStateChange( 36 virtual void OnSignalStrategyStateChange(
52 SignalStrategy::State state) OVERRIDE; 37 SignalStrategy::State state) OVERRIDE;
53 virtual bool OnSignalStrategyIncomingStanza( 38 virtual bool OnSignalStrategyIncomingStanza(
54 const buzz::XmlElement* stanza) OVERRIDE; 39 const buzz::XmlElement* stanza) OVERRIDE;
55 40
41 void Log(const ServerLogEntry& entry);
42
43 ServerLogEntry::Mode mode() { return mode_; }
44
56 private: 45 private:
57 void Log(const ServerLogEntry& entry);
58 void SendPendingEntries(); 46 void SendPendingEntries();
59 47
60 // Generates a new random session ID.
61 void GenerateSessionId();
62
63 // Expire the session ID if the maximum duration has been exceeded.
64 void MaybeExpireSessionId();
65
66 ServerLogEntry::Mode mode_; 48 ServerLogEntry::Mode mode_;
67 SignalStrategy* signal_strategy_; 49 SignalStrategy* signal_strategy_;
68 scoped_ptr<IqSender> iq_sender_; 50 scoped_ptr<IqSender> iq_sender_;
69 std::string directory_bot_jid_; 51 std::string directory_bot_jid_;
70 52
71 std::deque<ServerLogEntry> pending_entries_; 53 std::deque<ServerLogEntry> pending_entries_;
72 54
73 // A randomly generated session ID to be attached to log messages. This
74 // is regenerated at the start of a new session.
75 std::string session_id_;
76
77 // Start time of the session.
78 base::TimeTicks session_start_time_;
79
80 // Time when the session ID was generated.
81 base::TimeTicks session_id_generation_time_;
82
83 DISALLOW_COPY_AND_ASSIGN(LogToServer); 55 DISALLOW_COPY_AND_ASSIGN(LogToServer);
84 }; 56 };
85 57
86 } // namespace client
87
88 } // namespace remoting 58 } // namespace remoting
89 59
90 #endif // REMOTING_CLIENT_LOG_TO_SERVER_H_ 60 #endif // REMOTING_JINGLE_GLUE_LOG_TO_SERVER_H_
OLDNEW
« no previous file with comments | « remoting/host/remoting_me2me_host.cc ('k') | remoting/jingle_glue/log_to_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698