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

Unified Diff: remoting/host/log_to_server_host.cc

Issue 320403002: Pull out common code from client and host versions of LogToServer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/log_to_server_host.h ('k') | remoting/host/log_to_server_host_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/log_to_server_host.cc
diff --git a/remoting/host/log_to_server_host.cc b/remoting/host/log_to_server_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..270b9f5201e971a0cdf07b74046d8998327ca1e0
--- /dev/null
+++ b/remoting/host/log_to_server_host.cc
@@ -0,0 +1,69 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/log_to_server_host.h"
+
+#include "base/bind.h"
+#include "base/message_loop/message_loop_proxy.h"
+#include "remoting/base/constants.h"
+#include "remoting/host/host_status_monitor.h"
+#include "remoting/host/server_log_entry_host.h"
+#include "remoting/jingle_glue/server_log_entry.h"
+#include "remoting/protocol/transport.h"
+
+namespace remoting {
+
+LogToServerHost::LogToServerHost(base::WeakPtr<HostStatusMonitor> monitor,
+ ServerLogEntry::Mode mode,
+ SignalStrategy* signal_strategy,
+ const std::string& directory_bot_jid)
+ : LogToServer(mode, signal_strategy, directory_bot_jid),
+ monitor_(monitor) {
+ monitor_->AddStatusObserver(this);
+}
+
+LogToServerHost::~LogToServerHost() {
+ if (monitor_.get())
+ monitor_->RemoveStatusObserver(this);
+}
+
+void LogToServerHost::LogSessionStateChange(const std::string& jid,
+ bool connected) {
Sergey Ulanov 2014/06/27 20:50:10 nit: indentation
Lambros 2014/07/01 22:56:17 Done.
+ DCHECK(CalledOnValidThread());
+
+ scoped_ptr<ServerLogEntry> entry(
+ MakeLogEntryForSessionStateChange(connected));
+ AddHostFieldsToLogEntry(entry.get());
+ entry->AddModeField(mode());
+
+ if (connected) {
+ DCHECK(connection_route_type_.count(jid) == 1);
Sergey Ulanov 2014/06/27 20:50:10 DCHECK_EQ, or just remove '== 1'
Lambros 2014/07/01 22:56:17 Done.
+ AddConnectionTypeToLogEntry(entry.get(), connection_route_type_[jid]);
+ }
+ Log(*entry.get());
+}
+
+void LogToServerHost::OnClientConnected(const std::string& jid) {
+ DCHECK(CalledOnValidThread());
+ LogSessionStateChange(jid, true);
+}
+
+void LogToServerHost::OnClientDisconnected(const std::string& jid) {
+ DCHECK(CalledOnValidThread());
+ LogSessionStateChange(jid, false);
+ connection_route_type_.erase(jid);
+}
+
+void LogToServerHost::OnClientRouteChange(
+ const std::string& jid,
+ const std::string& channel_name,
+ const protocol::TransportRoute& route) {
+ // Store connection type for the video channel. It is logged later
+ // when client authentication is finished.
+ if (channel_name == kVideoChannelName) {
+ connection_route_type_[jid] = route.type;
+ }
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/host/log_to_server_host.h ('k') | remoting/host/log_to_server_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698