OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "content/renderer/media/peer_connection_tracker.h" | 4 #include "content/renderer/media/peer_connection_tracker.h" |
5 | 5 |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "content/common/media/peer_connection_tracker_messages.h" | 7 #include "content/common/media/peer_connection_tracker_messages.h" |
8 #include "content/renderer/media/rtc_media_constraints.h" | 8 #include "content/renderer/media/rtc_media_constraints.h" |
9 #include "content/renderer/media/rtc_peer_connection_handler.h" | 9 #include "content/renderer/media/rtc_peer_connection_handler.h" |
10 #include "content/renderer/render_thread_impl.h" | 10 #include "content/renderer/render_thread_impl.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 GET_STRING_OF_STATE(ICEGatheringStateComplete) | 145 GET_STRING_OF_STATE(ICEGatheringStateComplete) |
146 default: | 146 default: |
147 NOTREACHED(); | 147 NOTREACHED(); |
148 break; | 148 break; |
149 } | 149 } |
150 return result; | 150 return result; |
151 } | 151 } |
152 | 152 |
153 // Builds a DictionaryValue from the StatsReport. | 153 // Builds a DictionaryValue from the StatsReport. |
154 // The caller takes the ownership of the returned value. | 154 // The caller takes the ownership of the returned value. |
| 155 // Note: |
| 156 // The format must be consistent with what webrtc_internals.js expects. |
| 157 // If you change it here, you must change webrtc_internals.js as well. |
155 static DictionaryValue* GetDictValueStats(const webrtc::StatsReport& report) { | 158 static DictionaryValue* GetDictValueStats(const webrtc::StatsReport& report) { |
156 if (report.values.empty()) | 159 if (report.values.empty()) |
157 return NULL; | 160 return NULL; |
158 | 161 |
159 DictionaryValue* dict = new DictionaryValue(); | 162 DictionaryValue* dict = new DictionaryValue(); |
160 if (!dict) | 163 if (!dict) |
161 return NULL; | 164 return NULL; |
162 dict->SetDouble("timestamp", report.timestamp); | 165 dict->SetDouble("timestamp", report.timestamp); |
163 | 166 |
164 ListValue* values = new ListValue(); | 167 ListValue* values = new ListValue(); |
(...skipping 16 matching lines...) Expand all Loading... |
181 scoped_ptr<DictionaryValue> stats, result; | 184 scoped_ptr<DictionaryValue> stats, result; |
182 | 185 |
183 stats.reset(GetDictValueStats(report)); | 186 stats.reset(GetDictValueStats(report)); |
184 if (!stats) | 187 if (!stats) |
185 return NULL; | 188 return NULL; |
186 | 189 |
187 result.reset(new DictionaryValue()); | 190 result.reset(new DictionaryValue()); |
188 if (!result) | 191 if (!result) |
189 return NULL; | 192 return NULL; |
190 | 193 |
| 194 // Note: |
| 195 // The format must be consistent with what webrtc_internals.js expects. |
| 196 // If you change it here, you must change webrtc_internals.js as well. |
191 if (stats) | 197 if (stats) |
192 result->Set("stats", stats.release()); | 198 result->Set("stats", stats.release()); |
193 result->SetString("id", report.id); | 199 result->SetString("id", report.id); |
194 result->SetString("type", report.type); | 200 result->SetString("type", report.type); |
195 | 201 |
196 return result.release(); | 202 return result.release(); |
197 } | 203 } |
198 | 204 |
199 class InternalStatsObserver : public webrtc::StatsObserver { | 205 class InternalStatsObserver : public webrtc::StatsObserver { |
200 public: | 206 public: |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 const std::string& value) { | 453 const std::string& value) { |
448 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end()) | 454 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end()) |
449 return; | 455 return; |
450 | 456 |
451 RenderThreadImpl::current()->Send( | 457 RenderThreadImpl::current()->Send( |
452 new PeerConnectionTrackerHost_UpdatePeerConnection( | 458 new PeerConnectionTrackerHost_UpdatePeerConnection( |
453 peer_connection_id_map_[pc_handler], type, value)); | 459 peer_connection_id_map_[pc_handler], type, value)); |
454 } | 460 } |
455 | 461 |
456 } // namespace content | 462 } // namespace content |
OLD | NEW |