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

Side by Side Diff: remoting/client/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/client/jni/chromoting_jni_instance.cc ('k') | remoting/client/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
(Empty)
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_LOG_TO_SERVER_H_
6 #define REMOTING_CLIENT_LOG_TO_SERVER_H_
7
8 #include <deque>
9 #include <map>
10 #include <string>
11
12 #include "base/threading/non_thread_safe.h"
13 #include "base/time/time.h"
14 #include "remoting/jingle_glue/server_log_entry.h"
15 #include "remoting/jingle_glue/signal_strategy.h"
16 #include "remoting/protocol/connection_to_host.h"
17 #include "remoting/protocol/errors.h"
18
19 namespace buzz {
20 class XmlElement;
21 } // namespace buzz
22
23 namespace remoting {
24
25 class ChromotingStats;
26 class IqSender;
27
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.
35 // The contents of the log entries are described in server_log_entry.cc.
36 // They do not contain any personally identifiable information.
37 class LogToServer : public base::NonThreadSafe,
38 public SignalStrategy::Listener {
39 public:
40 LogToServer(ServerLogEntry::Mode mode,
41 SignalStrategy* signal_strategy,
42 const std::string& directory_bot_jid);
43 virtual ~LogToServer();
44
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.
51 virtual void OnSignalStrategyStateChange(
52 SignalStrategy::State state) OVERRIDE;
53 virtual bool OnSignalStrategyIncomingStanza(
54 const buzz::XmlElement* stanza) OVERRIDE;
55
56 private:
57 void Log(const ServerLogEntry& entry);
58 void SendPendingEntries();
59
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_;
67 SignalStrategy* signal_strategy_;
68 scoped_ptr<IqSender> iq_sender_;
69 std::string directory_bot_jid_;
70
71 std::deque<ServerLogEntry> pending_entries_;
72
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);
84 };
85
86 } // namespace client
87
88 } // namespace remoting
89
90 #endif // REMOTING_CLIENT_LOG_TO_SERVER_H_
OLDNEW
« no previous file with comments | « remoting/client/jni/chromoting_jni_instance.cc ('k') | remoting/client/log_to_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698