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

Side by Side Diff: remoting/client/server_log_entry_client.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/client/server_log_entry_client.h" 5 #include "remoting/client/server_log_entry_client.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringize_macros.h" 9 #include "base/strings/stringize_macros.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return "host-configuration-error"; 88 return "host-configuration-error";
89 case protocol::UNKNOWN_ERROR: 89 case protocol::UNKNOWN_ERROR:
90 return "unknown-error"; 90 return "unknown-error";
91 } 91 }
92 NOTREACHED(); 92 NOTREACHED();
93 return nullptr; 93 return nullptr;
94 } 94 }
95 95
96 } // namespace 96 } // namespace
97 97
98 scoped_ptr<ServerLogEntry> MakeLogEntryForSessionStateChange( 98 std::unique_ptr<ServerLogEntry> MakeLogEntryForSessionStateChange(
99 ConnectionToHost::State state, 99 ConnectionToHost::State state,
100 ErrorCode error) { 100 ErrorCode error) {
101 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); 101 std::unique_ptr<ServerLogEntry> entry(new ServerLogEntry());
102 entry->AddRoleField(kValueRoleClient); 102 entry->AddRoleField(kValueRoleClient);
103 entry->AddEventNameField(kValueEventNameSessionState); 103 entry->AddEventNameField(kValueEventNameSessionState);
104 104
105 entry->Set(kKeySessionState, GetValueSessionState(state)); 105 entry->Set(kKeySessionState, GetValueSessionState(state));
106 if (error != protocol::OK) { 106 if (error != protocol::OK) {
107 entry->Set(kKeyConnectionError, GetValueError(error)); 107 entry->Set(kKeyConnectionError, GetValueError(error));
108 } 108 }
109 109
110 return entry; 110 return entry;
111 } 111 }
112 112
113 scoped_ptr<ServerLogEntry> MakeLogEntryForStatistics( 113 std::unique_ptr<ServerLogEntry> MakeLogEntryForStatistics(
114 protocol::PerformanceTracker* perf_tracker) { 114 protocol::PerformanceTracker* perf_tracker) {
115 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); 115 std::unique_ptr<ServerLogEntry> entry(new ServerLogEntry());
116 entry->AddRoleField(kValueRoleClient); 116 entry->AddRoleField(kValueRoleClient);
117 entry->AddEventNameField(kValueEventNameStatistics); 117 entry->AddEventNameField(kValueEventNameStatistics);
118 118
119 entry->Set("video-bandwidth", 119 entry->Set("video-bandwidth",
120 StringPrintf("%.2f", perf_tracker->video_bandwidth())); 120 StringPrintf("%.2f", perf_tracker->video_bandwidth()));
121 entry->Set("capture-latency", 121 entry->Set("capture-latency",
122 StringPrintf("%.2f", perf_tracker->video_capture_ms().Average())); 122 StringPrintf("%.2f", perf_tracker->video_capture_ms().Average()));
123 entry->Set("encode-latency", 123 entry->Set("encode-latency",
124 StringPrintf("%.2f", perf_tracker->video_encode_ms().Average())); 124 StringPrintf("%.2f", perf_tracker->video_encode_ms().Average()));
125 entry->Set("decode-latency", 125 entry->Set("decode-latency",
126 StringPrintf("%.2f", perf_tracker->video_decode_ms().Average())); 126 StringPrintf("%.2f", perf_tracker->video_decode_ms().Average()));
127 entry->Set("render-latency", 127 entry->Set("render-latency",
128 StringPrintf("%.2f", perf_tracker->video_paint_ms().Average())); 128 StringPrintf("%.2f", perf_tracker->video_paint_ms().Average()));
129 entry->Set("roundtrip-latency", 129 entry->Set("roundtrip-latency",
130 StringPrintf("%.2f", perf_tracker->round_trip_ms().Average())); 130 StringPrintf("%.2f", perf_tracker->round_trip_ms().Average()));
131 131
132 return entry; 132 return entry;
133 } 133 }
134 134
135 scoped_ptr<ServerLogEntry> MakeLogEntryForSessionIdOld( 135 std::unique_ptr<ServerLogEntry> MakeLogEntryForSessionIdOld(
136 const std::string& session_id) { 136 const std::string& session_id) {
137 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); 137 std::unique_ptr<ServerLogEntry> entry(new ServerLogEntry());
138 entry->AddRoleField(kValueRoleClient); 138 entry->AddRoleField(kValueRoleClient);
139 entry->AddEventNameField(kValueEventNameSessionIdOld); 139 entry->AddEventNameField(kValueEventNameSessionIdOld);
140 AddSessionIdToLogEntry(entry.get(), session_id); 140 AddSessionIdToLogEntry(entry.get(), session_id);
141 return entry; 141 return entry;
142 } 142 }
143 143
144 scoped_ptr<ServerLogEntry> MakeLogEntryForSessionIdNew( 144 std::unique_ptr<ServerLogEntry> MakeLogEntryForSessionIdNew(
145 const std::string& session_id) { 145 const std::string& session_id) {
146 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); 146 std::unique_ptr<ServerLogEntry> entry(new ServerLogEntry());
147 entry->AddRoleField(kValueRoleClient); 147 entry->AddRoleField(kValueRoleClient);
148 entry->AddEventNameField(kValueEventNameSessionIdNew); 148 entry->AddEventNameField(kValueEventNameSessionIdNew);
149 AddSessionIdToLogEntry(entry.get(), session_id); 149 AddSessionIdToLogEntry(entry.get(), session_id);
150 return entry; 150 return entry;
151 } 151 }
152 152
153 void AddClientFieldsToLogEntry(ServerLogEntry* entry) { 153 void AddClientFieldsToLogEntry(ServerLogEntry* entry) {
154 entry->Set(kKeyOsName, SysInfo::OperatingSystemName()); 154 entry->Set(kKeyOsName, SysInfo::OperatingSystemName());
155 entry->Set(kKeyOsVersion, SysInfo::OperatingSystemVersion()); 155 entry->Set(kKeyOsVersion, SysInfo::OperatingSystemVersion());
156 entry->Set(kKeyAppVersion, STRINGIZE(VERSION)); 156 entry->Set(kKeyAppVersion, STRINGIZE(VERSION));
157 entry->AddCpuField(); 157 entry->AddCpuField();
158 } 158 }
159 159
160 void AddSessionIdToLogEntry(ServerLogEntry* entry, const std::string& id) { 160 void AddSessionIdToLogEntry(ServerLogEntry* entry, const std::string& id) {
161 entry->Set(kKeySessionId, id); 161 entry->Set(kKeySessionId, id);
162 } 162 }
163 163
164 void AddSessionDurationToLogEntry(ServerLogEntry* entry, 164 void AddSessionDurationToLogEntry(ServerLogEntry* entry,
165 base::TimeDelta duration) { 165 base::TimeDelta duration) {
166 entry->Set(kKeySessionDuration, base::Int64ToString(duration.InSeconds())); 166 entry->Set(kKeySessionDuration, base::Int64ToString(duration.InSeconds()));
167 } 167 }
168 168
169 } // namespace remoting 169 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/server_log_entry_client.h ('k') | remoting/client/server_log_entry_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698