OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "remoting/host/host_status_observer.h" | 12 #include "remoting/host/host_status_observer.h" |
13 #include "remoting/host/server_log_entry.h" | 13 #include "remoting/host/server_log_entry.h" |
| 14 #include "remoting/jingle_glue/signal_strategy.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 class MessageLoopProxy; | 17 class MessageLoopProxy; |
17 } // namespace base | 18 } // namespace base |
18 | 19 |
19 namespace buzz { | 20 namespace buzz { |
20 class XmlElement; | 21 class XmlElement; |
21 } // namespace buzz | 22 } // namespace buzz |
22 | 23 |
23 namespace remoting { | 24 namespace remoting { |
24 | 25 |
| 26 class ChromotingHost; |
25 class IqSender; | 27 class IqSender; |
26 | 28 |
27 /** | 29 // LogToServer sends log entries to a server. |
28 * A class that sends log entries to a server. | 30 class LogToServer : public HostStatusObserver, |
29 * | 31 public SignalStrategy::Listener { |
30 * The class is not thread-safe. | |
31 */ | |
32 class LogToServer : public HostStatusObserver { | |
33 public: | 32 public: |
34 explicit LogToServer(base::MessageLoopProxy* message_loop); | 33 explicit LogToServer(SignalStrategy* signal_strategy); |
35 virtual ~LogToServer(); | 34 virtual ~LogToServer(); |
36 | 35 |
37 // Logs a session state change. | 36 // Logs a session state change. |
38 // Currently, this is either connection or disconnection. | 37 // Currently, this is either connection or disconnection. |
39 void LogSessionStateChange(bool connected); | 38 void LogSessionStateChange(bool connected); |
40 | 39 |
41 // HostStatusObserver implementation. | 40 // SignalStrategy::Listener interface. |
42 virtual void OnSignallingConnected(SignalStrategy* signal_strategy) OVERRIDE; | 41 virtual void OnSignalStrategyStateChange( |
43 virtual void OnSignallingDisconnected() OVERRIDE; | 42 SignalStrategy::State state) OVERRIDE; |
| 43 |
| 44 // HostStatusObserver interface. |
44 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; | 45 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; |
45 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; | 46 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; |
46 virtual void OnAccessDenied() OVERRIDE; | 47 virtual void OnAccessDenied() OVERRIDE; |
47 virtual void OnShutdown() OVERRIDE; | 48 virtual void OnShutdown() OVERRIDE; |
48 | 49 |
49 private: | 50 private: |
50 void Log(const ServerLogEntry& entry); | 51 void Log(const ServerLogEntry& entry); |
51 void SendPendingEntries(); | 52 void SendPendingEntries(); |
52 | 53 |
53 scoped_refptr<base::MessageLoopProxy> message_loop_; | 54 scoped_refptr<ChromotingHost> host_; |
| 55 SignalStrategy* signal_strategy_; |
54 scoped_ptr<IqSender> iq_sender_; | 56 scoped_ptr<IqSender> iq_sender_; |
55 std::deque<ServerLogEntry> pending_entries_; | 57 std::deque<ServerLogEntry> pending_entries_; |
56 | 58 |
57 DISALLOW_COPY_AND_ASSIGN(LogToServer); | 59 DISALLOW_COPY_AND_ASSIGN(LogToServer); |
58 }; | 60 }; |
59 | 61 |
60 } // namespace remoting | 62 } // namespace remoting |
61 | 63 |
62 #endif // REMOTING_HOST_LOG_TO_SERVER_H_ | 64 #endif // REMOTING_HOST_LOG_TO_SERVER_H_ |
OLD | NEW |