| OLD | NEW |
| 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 "content/renderer/media/rtc_data_channel_handler.h" | 5 #include "content/renderer/media/rtc_data_channel_handler.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 void RtcDataChannelHandler::OnMessage(scoped_ptr<webrtc::DataBuffer> buffer) { | 286 void RtcDataChannelHandler::OnMessage(scoped_ptr<webrtc::DataBuffer> buffer) { |
| 287 DCHECK(thread_checker_.CalledOnValidThread()); | 287 DCHECK(thread_checker_.CalledOnValidThread()); |
| 288 if (!webkit_client_) { | 288 if (!webkit_client_) { |
| 289 // If this happens, the web application will not get notified of changes. | 289 // If this happens, the web application will not get notified of changes. |
| 290 NOTREACHED() << "WebRTCDataChannelHandlerClient not set."; | 290 NOTREACHED() << "WebRTCDataChannelHandlerClient not set."; |
| 291 return; | 291 return; |
| 292 } | 292 } |
| 293 | 293 |
| 294 if (buffer->binary) { | 294 if (buffer->binary) { |
| 295 webkit_client_->didReceiveRawData(buffer->data.data(), | 295 webkit_client_->didReceiveRawData(buffer->data.data(), |
| 296 buffer->data.length()); | 296 buffer->data.size()); |
| 297 } else { | 297 } else { |
| 298 base::string16 utf16; | 298 base::string16 utf16; |
| 299 if (!base::UTF8ToUTF16(buffer->data.data(), buffer->data.length(), | 299 if (!base::UTF8ToUTF16(buffer->data.data(), buffer->data.size(), |
| 300 &utf16)) { | 300 &utf16)) { |
| 301 LOG(ERROR) << "Failed convert received data to UTF16"; | 301 LOG(ERROR) << "Failed convert received data to UTF16"; |
| 302 return; | 302 return; |
| 303 } | 303 } |
| 304 webkit_client_->didReceiveStringData(utf16); | 304 webkit_client_->didReceiveStringData(utf16); |
| 305 } | 305 } |
| 306 } | 306 } |
| 307 | 307 |
| 308 void RtcDataChannelHandler::RecordMessageSent(size_t num_bytes) { | 308 void RtcDataChannelHandler::RecordMessageSent(size_t num_bytes) { |
| 309 DCHECK(thread_checker_.CalledOnValidThread()); | 309 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 324 num_bytes, | 324 num_bytes, |
| 325 1, kMaxBucketSize, kNumBuckets); | 325 1, kMaxBucketSize, kNumBuckets); |
| 326 } else { | 326 } else { |
| 327 UMA_HISTOGRAM_CUSTOM_COUNTS("WebRTC.UnreliableDataChannelMessageSize", | 327 UMA_HISTOGRAM_CUSTOM_COUNTS("WebRTC.UnreliableDataChannelMessageSize", |
| 328 num_bytes, | 328 num_bytes, |
| 329 1, kMaxBucketSize, kNumBuckets); | 329 1, kMaxBucketSize, kNumBuckets); |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 | 332 |
| 333 } // namespace content | 333 } // namespace content |
| OLD | NEW |