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

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

Issue 9727005: Log connection type to syslogs and to the server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
« no previous file with comments | « remoting/host/log_to_server.h ('k') | remoting/host/log_to_server_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "remoting/host/log_to_server.h" 5 #include "remoting/host/log_to_server.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "remoting/base/constants.h" 9 #include "remoting/base/constants.h"
10 #include "remoting/host/chromoting_host.h" 10 #include "remoting/host/chromoting_host.h"
11 #include "remoting/host/server_log_entry.h" 11 #include "remoting/host/server_log_entry.h"
12 #include "remoting/jingle_glue/iq_sender.h" 12 #include "remoting/jingle_glue/iq_sender.h"
13 #include "remoting/jingle_glue/jingle_thread.h" 13 #include "remoting/jingle_glue/jingle_thread.h"
14 #include "remoting/jingle_glue/signal_strategy.h" 14 #include "remoting/jingle_glue/signal_strategy.h"
15 #include "remoting/protocol/transport.h"
15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 16 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
16 #include "third_party/libjingle/source/talk/xmpp/constants.h" 17 #include "third_party/libjingle/source/talk/xmpp/constants.h"
17 18
18 using buzz::QName; 19 using buzz::QName;
19 using buzz::XmlElement; 20 using buzz::XmlElement;
20 21
21 namespace remoting { 22 namespace remoting {
22 23
23 namespace { 24 namespace {
24 const char kLogCommand[] = "log"; 25 const char kLogCommand[] = "log";
25 } // namespace 26 } // namespace
26 27
27 LogToServer::LogToServer(ChromotingHost* host, 28 LogToServer::LogToServer(ChromotingHost* host,
28 ServerLogEntry::Mode mode, 29 ServerLogEntry::Mode mode,
29 SignalStrategy* signal_strategy) 30 SignalStrategy* signal_strategy)
30 : host_(host), 31 : host_(host),
31 mode_(mode), 32 mode_(mode),
32 signal_strategy_(signal_strategy) { 33 signal_strategy_(signal_strategy),
34 connection_type_set_(false) {
33 signal_strategy_->AddListener(this); 35 signal_strategy_->AddListener(this);
34 36
35 // |host| may be NULL in tests. 37 // |host| may be NULL in tests.
36 if (host_) 38 if (host_)
37 host_->AddStatusObserver(this); 39 host_->AddStatusObserver(this);
38 } 40 }
39 41
40 LogToServer::~LogToServer() { 42 LogToServer::~LogToServer() {
41 signal_strategy_->RemoveListener(this); 43 signal_strategy_->RemoveListener(this);
42 if (host_) 44 if (host_)
43 host_->RemoveStatusObserver(this); 45 host_->RemoveStatusObserver(this);
44 } 46 }
45 47
46 void LogToServer::LogSessionStateChange(bool connected) { 48 void LogToServer::LogSessionStateChange(bool connected) {
47 DCHECK(CalledOnValidThread()); 49 DCHECK(CalledOnValidThread());
48 50
49 scoped_ptr<ServerLogEntry> entry(ServerLogEntry::MakeSessionStateChange( 51 scoped_ptr<ServerLogEntry> entry(
50 connected)); 52 ServerLogEntry::MakeSessionStateChange(connected));
51 entry->AddHostFields(); 53 entry->AddHostFields();
52 entry->AddModeField(mode_); 54 entry->AddModeField(mode_);
55
56 if (connected) {
57 DCHECK(connection_type_set_);
58 entry->AddConnectionTypeField(connection_type_);
59 }
53 Log(*entry.get()); 60 Log(*entry.get());
54 } 61 }
55 62
56 void LogToServer::OnSignalStrategyStateChange(SignalStrategy::State state) { 63 void LogToServer::OnSignalStrategyStateChange(SignalStrategy::State state) {
57 DCHECK(CalledOnValidThread()); 64 DCHECK(CalledOnValidThread());
58 65
59 if (state == SignalStrategy::CONNECTED) { 66 if (state == SignalStrategy::CONNECTED) {
60 iq_sender_.reset(new IqSender(signal_strategy_)); 67 iq_sender_.reset(new IqSender(signal_strategy_));
61 SendPendingEntries(); 68 SendPendingEntries();
62 } else if (state == SignalStrategy::DISCONNECTED) { 69 } else if (state == SignalStrategy::DISCONNECTED) {
63 iq_sender_.reset(); 70 iq_sender_.reset();
64 } 71 }
65 } 72 }
66 73
67 void LogToServer::OnClientAuthenticated(const std::string& jid) { 74 void LogToServer::OnClientAuthenticated(const std::string& jid) {
68 DCHECK(CalledOnValidThread()); 75 DCHECK(CalledOnValidThread());
69 LogSessionStateChange(true); 76 LogSessionStateChange(true);
70 } 77 }
71 78
72 void LogToServer::OnClientDisconnected(const std::string& jid) { 79 void LogToServer::OnClientDisconnected(const std::string& jid) {
73 DCHECK(CalledOnValidThread()); 80 DCHECK(CalledOnValidThread());
74 LogSessionStateChange(false); 81 LogSessionStateChange(false);
82 connection_type_set_ = false;
75 } 83 }
76 84
77 void LogToServer::OnAccessDenied(const std::string& jid) { 85 void LogToServer::OnAccessDenied(const std::string& jid) {
78 } 86 }
79 87
88 void LogToServer::OnClientRouteChange(const std::string& jid,
89 const std::string& channel_name,
90 const protocol::TransportRoute& route) {
91 // Store connection type for the video channel. It is logged later
92 // when client authentication is finished.
93 if (channel_name == kVideoChannelName) {
94 connection_type_ = route.type;
95 connection_type_set_ = true;
96 }
97 }
98
80 void LogToServer::OnShutdown() { 99 void LogToServer::OnShutdown() {
81 } 100 }
82 101
83 void LogToServer::Log(const ServerLogEntry& entry) { 102 void LogToServer::Log(const ServerLogEntry& entry) {
84 pending_entries_.push_back(entry); 103 pending_entries_.push_back(entry);
85 SendPendingEntries(); 104 SendPendingEntries();
86 } 105 }
87 106
88 void LogToServer::SendPendingEntries() { 107 void LogToServer::SendPendingEntries() {
89 if (iq_sender_ == NULL) { 108 if (iq_sender_ == NULL) {
(...skipping 12 matching lines...) Expand all
102 } 121 }
103 // Send the stanza to the server. 122 // Send the stanza to the server.
104 scoped_ptr<IqRequest> req = iq_sender_->SendIq( 123 scoped_ptr<IqRequest> req = iq_sender_->SendIq(
105 buzz::STR_SET, kChromotingBotJid, stanza.Pass(), 124 buzz::STR_SET, kChromotingBotJid, stanza.Pass(),
106 IqSender::ReplyCallback()); 125 IqSender::ReplyCallback());
107 // We ignore any response, so let the IqRequest be destroyed. 126 // We ignore any response, so let the IqRequest be destroyed.
108 return; 127 return;
109 } 128 }
110 129
111 } // namespace remoting 130 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/log_to_server.h ('k') | remoting/host/log_to_server_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698