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

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

Issue 282063005: Pull out common code from client and host versions of ServerLogEntry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_HOST_LOG_TO_SERVER_H_ 5 #ifndef REMOTING_HOST_LOG_TO_SERVER_H_
6 #define REMOTING_HOST_LOG_TO_SERVER_H_ 6 #define REMOTING_HOST_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/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.h"
15 #include "remoting/host/host_status_observer.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" 16 #include "remoting/jingle_glue/signal_strategy.h"
17 #include "remoting/protocol/server_log_entry.h"
18 #include "remoting/protocol/transport.h" 18 #include "remoting/protocol/transport.h"
19 19
20 namespace base { 20 namespace base {
21 class MessageLoopProxy; 21 class MessageLoopProxy;
22 } // namespace base 22 } // namespace base
23 23
24 namespace buzz { 24 namespace buzz {
25 class XmlElement; 25 class XmlElement;
26 } // namespace buzz 26 } // namespace buzz
27 27
28 namespace remoting { 28 namespace remoting {
29 29
30 class HostStatusMonitor; 30 class HostStatusMonitor;
31 class IqSender; 31 class IqSender;
32 32
33 // LogToServer sends log entries to a server. 33 // LogToServer sends log entries to a server.
34 // The contents of the log entries are described in server_log_entry.cc. 34 // The contents of the log entries are described in server_log_entry.cc.
35 // They do not contain any personally identifiable information. 35 // They do not contain any personally identifiable information.
36 class LogToServer : public base::NonThreadSafe, 36 class LogToServer : public base::NonThreadSafe,
37 public HostStatusObserver, 37 public HostStatusObserver,
38 public SignalStrategy::Listener { 38 public SignalStrategy::Listener {
39 public: 39 public:
40 explicit LogToServer(base::WeakPtr<HostStatusMonitor> monitor, 40 explicit LogToServer(base::WeakPtr<HostStatusMonitor> monitor,
41 ServerLogEntry::Mode mode, 41 protocol::ServerLogEntry::Mode mode,
42 SignalStrategy* signal_strategy, 42 SignalStrategy* signal_strategy,
43 const std::string& directory_bot_jid); 43 const std::string& directory_bot_jid);
44 virtual ~LogToServer(); 44 virtual ~LogToServer();
45 45
46 // Logs a session state change. Currently, this is either 46 // Logs a session state change. Currently, this is either
47 // connection or disconnection. 47 // connection or disconnection.
48 void LogSessionStateChange(const std::string& jid, bool connected); 48 void LogSessionStateChange(const std::string& jid, bool connected);
49 49
50 // SignalStrategy::Listener interface. 50 // SignalStrategy::Listener interface.
51 virtual void OnSignalStrategyStateChange( 51 virtual void OnSignalStrategyStateChange(
52 SignalStrategy::State state) OVERRIDE; 52 SignalStrategy::State state) OVERRIDE;
53 virtual bool OnSignalStrategyIncomingStanza( 53 virtual bool OnSignalStrategyIncomingStanza(
54 const buzz::XmlElement* stanza) OVERRIDE; 54 const buzz::XmlElement* stanza) OVERRIDE;
55 55
56 // HostStatusObserver interface. 56 // HostStatusObserver interface.
57 virtual void OnClientConnected(const std::string& jid) OVERRIDE; 57 virtual void OnClientConnected(const std::string& jid) OVERRIDE;
58 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; 58 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE;
59 virtual void OnClientRouteChange( 59 virtual void OnClientRouteChange(
60 const std::string& jid, 60 const std::string& jid,
61 const std::string& channel_name, 61 const std::string& channel_name,
62 const protocol::TransportRoute& route) OVERRIDE; 62 const protocol::TransportRoute& route) OVERRIDE;
63 63
64 private: 64 private:
65 void Log(const ServerLogEntry& entry); 65 void Log(const protocol::ServerLogEntry& entry);
66 void SendPendingEntries(); 66 void SendPendingEntries();
67 67
68 base::WeakPtr<HostStatusMonitor> monitor_; 68 base::WeakPtr<HostStatusMonitor> monitor_;
69 ServerLogEntry::Mode mode_; 69 protocol::ServerLogEntry::Mode mode_;
70 SignalStrategy* signal_strategy_; 70 SignalStrategy* signal_strategy_;
71 scoped_ptr<IqSender> iq_sender_; 71 scoped_ptr<IqSender> iq_sender_;
72 std::string directory_bot_jid_; 72 std::string directory_bot_jid_;
73 73
74 // A map from client JID to the route type of that client's connection to 74 // A map from client JID to the route type of that client's connection to
75 // this host. 75 // this host.
76 std::map<std::string, protocol::TransportRoute::RouteType> 76 std::map<std::string, protocol::TransportRoute::RouteType>
77 connection_route_type_; 77 connection_route_type_;
78 std::deque<ServerLogEntry> pending_entries_; 78 std::deque<protocol::ServerLogEntry> pending_entries_;
79 79
80 DISALLOW_COPY_AND_ASSIGN(LogToServer); 80 DISALLOW_COPY_AND_ASSIGN(LogToServer);
81 }; 81 };
82 82
83 } // namespace remoting 83 } // namespace remoting
84 84
85 #endif // REMOTING_HOST_LOG_TO_SERVER_H_ 85 #endif // REMOTING_HOST_LOG_TO_SERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698