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_
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"
21 class MessageLoopProxy
;
30 class HostStatusMonitor
;
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
{
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
;
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
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_