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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/host/log_to_server_host.h"
6
7 #include "base/bind.h"
8 #include "base/message_loop/message_loop_proxy.h"
9 #include "remoting/base/constants.h"
10 #include "remoting/host/host_status_monitor.h"
11 #include "remoting/host/server_log_entry_host.h"
12 #include "remoting/jingle_glue/server_log_entry.h"
13 #include "remoting/protocol/transport.h"
14
15 namespace remoting {
16
17 LogToServerHost::LogToServerHost(base::WeakPtr<HostStatusMonitor> monitor,
18 ServerLogEntry::Mode mode,
19 SignalStrategy* signal_strategy,
20 const std::string& directory_bot_jid)
21 : LogToServer(mode, signal_strategy, directory_bot_jid),
22 monitor_(monitor) {
23 monitor_->AddStatusObserver(this);
24 }
25
26 LogToServerHost::~LogToServerHost() {
27 if (monitor_.get())
28 monitor_->RemoveStatusObserver(this);
29 }
30
31 void LogToServerHost::LogSessionStateChange(const std::string& jid,
32 bool connected) {
Sergey Ulanov 2014/06/27 20:50:10 nit: indentation
Lambros 2014/07/01 22:56:17 Done.
33 DCHECK(CalledOnValidThread());
34
35 scoped_ptr<ServerLogEntry> entry(
36 MakeLogEntryForSessionStateChange(connected));
37 AddHostFieldsToLogEntry(entry.get());
38 entry->AddModeField(mode());
39
40 if (connected) {
41 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.
42 AddConnectionTypeToLogEntry(entry.get(), connection_route_type_[jid]);
43 }
44 Log(*entry.get());
45 }
46
47 void LogToServerHost::OnClientConnected(const std::string& jid) {
48 DCHECK(CalledOnValidThread());
49 LogSessionStateChange(jid, true);
50 }
51
52 void LogToServerHost::OnClientDisconnected(const std::string& jid) {
53 DCHECK(CalledOnValidThread());
54 LogSessionStateChange(jid, false);
55 connection_route_type_.erase(jid);
56 }
57
58 void LogToServerHost::OnClientRouteChange(
59 const std::string& jid,
60 const std::string& channel_name,
61 const protocol::TransportRoute& route) {
62 // Store connection type for the video channel. It is logged later
63 // when client authentication is finished.
64 if (channel_name == kVideoChannelName) {
65 connection_route_type_[jid] = route.type;
66 }
67 }
68
69 } // namespace remoting
OLDNEW
« 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