Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / remoting / host / host_status_logger.h
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_HOST_HOST_STATUS_LOGGER_H_
6 #define REMOTING_HOST_HOST_STATUS_LOGGER_H_
7
8 #include <map>
9
10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/non_thread_safe.h"
12 #include "remoting/host/host_status_observer.h"
13 #include "remoting/protocol/transport.h"
14 #include "remoting/signaling/log_to_server.h"
15
16 namespace remoting {
17
18 class HostStatusMonitor;
19
20 // HostStatusLogger sends host log entries to a server.
21 // The contents of the log entries are described in server_log_entry_host.cc.
22 // They do not contain any personally identifiable information.
23 class HostStatusLogger : public HostStatusObserver,
24                          public base::NonThreadSafe {
25  public:
26   HostStatusLogger(base::WeakPtr<HostStatusMonitor> monitor,
27                   ServerLogEntry::Mode mode,
28                   SignalStrategy* signal_strategy,
29                   const std::string& directory_bot_jid);
30   ~HostStatusLogger() override;
31
32   // Logs a session state change. Currently, this is either
33   // connection or disconnection.
34   void LogSessionStateChange(const std::string& jid, bool connected);
35
36   // HostStatusObserver interface.
37   void OnClientConnected(const std::string& jid) override;
38   void OnClientDisconnected(const std::string& jid) override;
39   void OnClientRouteChange(const std::string& jid,
40                            const std::string& channel_name,
41                            const protocol::TransportRoute& route) override;
42
43   // Allows test code to fake SignalStrategy state change events.
44   void SetSignalingStateForTest(SignalStrategy::State state);
45
46  private:
47   LogToServer log_to_server_;
48
49   base::WeakPtr<HostStatusMonitor> monitor_;
50
51   // A map from client JID to the route type of that client's connection to
52   // this host.
53   std::map<std::string, protocol::TransportRoute::RouteType>
54       connection_route_type_;
55
56   DISALLOW_COPY_AND_ASSIGN(HostStatusLogger);
57 };
58
59 }  // namespace remoting
60
61 #endif  // REMOTING_HOST_HOST_STATUS_LOGGER_H_