Revert 264226 "Reduce dependency of TiclInvalidationService on P..."
[chromium-blink-merge.git] / remoting / host / log_to_server.h
blobbbd920c44134ef08cab6b7d80977c0f0fbfcca69
1 // Copyright (c) 2012 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_HOST_LOG_TO_SERVER_H_
6 #define REMOTING_HOST_LOG_TO_SERVER_H_
8 #include <deque>
9 #include <map>
10 #include <string>
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/non_thread_safe.h"
15 #include "remoting/host/host_status_observer.h"
16 #include "remoting/host/server_log_entry.h"
17 #include "remoting/jingle_glue/signal_strategy.h"
18 #include "remoting/protocol/transport.h"
20 namespace base {
21 class MessageLoopProxy;
22 } // namespace base
24 namespace buzz {
25 class XmlElement;
26 } // namespace buzz
28 namespace remoting {
30 class HostStatusMonitor;
31 class IqSender;
33 // LogToServer sends log entries to a server.
34 // The contents of the log entries are described in server_log_entry.cc.
35 // They do not contain any personally identifiable information.
36 class LogToServer : public base::NonThreadSafe,
37 public HostStatusObserver,
38 public SignalStrategy::Listener {
39 public:
40 explicit LogToServer(base::WeakPtr<HostStatusMonitor> monitor,
41 ServerLogEntry::Mode mode,
42 SignalStrategy* signal_strategy,
43 const std::string& directory_bot_jid);
44 virtual ~LogToServer();
46 // Logs a session state change. Currently, this is either
47 // connection or disconnection.
48 void LogSessionStateChange(const std::string& jid, bool connected);
50 // SignalStrategy::Listener interface.
51 virtual void OnSignalStrategyStateChange(
52 SignalStrategy::State state) OVERRIDE;
53 virtual bool OnSignalStrategyIncomingStanza(
54 const buzz::XmlElement* stanza) OVERRIDE;
56 // HostStatusObserver interface.
57 virtual void OnClientConnected(const std::string& jid) OVERRIDE;
58 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE;
59 virtual void OnClientRouteChange(
60 const std::string& jid,
61 const std::string& channel_name,
62 const protocol::TransportRoute& route) OVERRIDE;
64 private:
65 void Log(const ServerLogEntry& entry);
66 void SendPendingEntries();
68 base::WeakPtr<HostStatusMonitor> monitor_;
69 ServerLogEntry::Mode mode_;
70 SignalStrategy* signal_strategy_;
71 scoped_ptr<IqSender> iq_sender_;
72 std::string directory_bot_jid_;
74 // A map from client JID to the route type of that client's connection to
75 // this host.
76 std::map<std::string, protocol::TransportRoute::RouteType>
77 connection_route_type_;
78 std::deque<ServerLogEntry> pending_entries_;
80 DISALLOW_COPY_AND_ASSIGN(LogToServer);
83 } // namespace remoting
85 #endif // REMOTING_HOST_LOG_TO_SERVER_H_