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

Side by Side Diff: content/renderer/media/rtc_data_channel_handler.cc

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
OLDNEW
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 <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 RtcDataChannelHandler::RtcDataChannelHandler( 14 RtcDataChannelHandler::RtcDataChannelHandler(
15 webrtc::DataChannelInterface* channel) 15 webrtc::DataChannelInterface* channel)
16 : channel_(channel), 16 : channel_(channel),
17 webkit_client_(NULL) { 17 webkit_client_(NULL) {
18 DVLOG(1) << "::ctor"; 18 DVLOG(1) << "::ctor";
19 channel_->RegisterObserver(this); 19 channel_->RegisterObserver(this);
20 } 20 }
21 21
22 RtcDataChannelHandler::~RtcDataChannelHandler() { 22 RtcDataChannelHandler::~RtcDataChannelHandler() {
23 DVLOG(1) << "::dtor"; 23 DVLOG(1) << "::dtor";
24 channel_->UnregisterObserver(); 24 channel_->UnregisterObserver();
25 } 25 }
26 26
27 void RtcDataChannelHandler::setClient( 27 void RtcDataChannelHandler::setClient(
28 WebKit::WebRTCDataChannelHandlerClient* client) { 28 blink::WebRTCDataChannelHandlerClient* client) {
29 webkit_client_ = client; 29 webkit_client_ = client;
30 } 30 }
31 31
32 WebKit::WebString RtcDataChannelHandler::label() { 32 blink::WebString RtcDataChannelHandler::label() {
33 return UTF8ToUTF16(channel_->label()); 33 return UTF8ToUTF16(channel_->label());
34 } 34 }
35 35
36 bool RtcDataChannelHandler::isReliable() { 36 bool RtcDataChannelHandler::isReliable() {
37 return channel_->reliable(); 37 return channel_->reliable();
38 } 38 }
39 39
40 bool RtcDataChannelHandler::ordered() const { 40 bool RtcDataChannelHandler::ordered() const {
41 return channel_->ordered(); 41 return channel_->ordered();
42 } 42 }
43 43
44 unsigned short RtcDataChannelHandler::maxRetransmitTime() const { 44 unsigned short RtcDataChannelHandler::maxRetransmitTime() const {
45 return channel_->maxRetransmitTime(); 45 return channel_->maxRetransmitTime();
46 } 46 }
47 47
48 unsigned short RtcDataChannelHandler::maxRetransmits() const { 48 unsigned short RtcDataChannelHandler::maxRetransmits() const {
49 return channel_->maxRetransmits(); 49 return channel_->maxRetransmits();
50 } 50 }
51 51
52 WebKit::WebString RtcDataChannelHandler::protocol() const { 52 blink::WebString RtcDataChannelHandler::protocol() const {
53 return UTF8ToUTF16(channel_->protocol()); 53 return UTF8ToUTF16(channel_->protocol());
54 } 54 }
55 55
56 bool RtcDataChannelHandler::negotiated() const { 56 bool RtcDataChannelHandler::negotiated() const {
57 return channel_->negotiated(); 57 return channel_->negotiated();
58 } 58 }
59 59
60 unsigned short RtcDataChannelHandler::id() const { 60 unsigned short RtcDataChannelHandler::id() const {
61 return channel_->id(); 61 return channel_->id();
62 } 62 }
63 63
64 unsigned long RtcDataChannelHandler::bufferedAmount() { 64 unsigned long RtcDataChannelHandler::bufferedAmount() {
65 return channel_->buffered_amount(); 65 return channel_->buffered_amount();
66 } 66 }
67 67
68 bool RtcDataChannelHandler::sendStringData(const WebKit::WebString& data) { 68 bool RtcDataChannelHandler::sendStringData(const blink::WebString& data) {
69 std::string utf8_buffer = UTF16ToUTF8(data); 69 std::string utf8_buffer = UTF16ToUTF8(data);
70 talk_base::Buffer buffer(utf8_buffer.c_str(), utf8_buffer.length()); 70 talk_base::Buffer buffer(utf8_buffer.c_str(), utf8_buffer.length());
71 webrtc::DataBuffer data_buffer(buffer, false); 71 webrtc::DataBuffer data_buffer(buffer, false);
72 return channel_->Send(data_buffer); 72 return channel_->Send(data_buffer);
73 } 73 }
74 74
75 bool RtcDataChannelHandler::sendRawData(const char* data, size_t length) { 75 bool RtcDataChannelHandler::sendRawData(const char* data, size_t length) {
76 talk_base::Buffer buffer(data, length); 76 talk_base::Buffer buffer(data, length);
77 webrtc::DataBuffer data_buffer(buffer, true); 77 webrtc::DataBuffer data_buffer(buffer, true);
78 return channel_->Send(data_buffer); 78 return channel_->Send(data_buffer);
79 } 79 }
80 80
81 void RtcDataChannelHandler::close() { 81 void RtcDataChannelHandler::close() {
82 channel_->Close(); 82 channel_->Close();
83 } 83 }
84 84
85 void RtcDataChannelHandler::OnStateChange() { 85 void RtcDataChannelHandler::OnStateChange() {
86 if (!webkit_client_) { 86 if (!webkit_client_) {
87 LOG(ERROR) << "WebRTCDataChannelHandlerClient not set."; 87 LOG(ERROR) << "WebRTCDataChannelHandlerClient not set.";
88 return; 88 return;
89 } 89 }
90 DVLOG(1) << "OnStateChange " << channel_->state(); 90 DVLOG(1) << "OnStateChange " << channel_->state();
91 switch (channel_->state()) { 91 switch (channel_->state()) {
92 case webrtc::DataChannelInterface::kConnecting: 92 case webrtc::DataChannelInterface::kConnecting:
93 webkit_client_->didChangeReadyState( 93 webkit_client_->didChangeReadyState(
94 WebKit::WebRTCDataChannelHandlerClient::ReadyStateConnecting); 94 blink::WebRTCDataChannelHandlerClient::ReadyStateConnecting);
95 break; 95 break;
96 case webrtc::DataChannelInterface::kOpen: 96 case webrtc::DataChannelInterface::kOpen:
97 webkit_client_->didChangeReadyState( 97 webkit_client_->didChangeReadyState(
98 WebKit::WebRTCDataChannelHandlerClient::ReadyStateOpen); 98 blink::WebRTCDataChannelHandlerClient::ReadyStateOpen);
99 break; 99 break;
100 case webrtc::DataChannelInterface::kClosing: 100 case webrtc::DataChannelInterface::kClosing:
101 webkit_client_->didChangeReadyState( 101 webkit_client_->didChangeReadyState(
102 WebKit::WebRTCDataChannelHandlerClient::ReadyStateClosing); 102 blink::WebRTCDataChannelHandlerClient::ReadyStateClosing);
103 break; 103 break;
104 case webrtc::DataChannelInterface::kClosed: 104 case webrtc::DataChannelInterface::kClosed:
105 webkit_client_->didChangeReadyState( 105 webkit_client_->didChangeReadyState(
106 WebKit::WebRTCDataChannelHandlerClient::ReadyStateClosed); 106 blink::WebRTCDataChannelHandlerClient::ReadyStateClosed);
107 break; 107 break;
108 default: 108 default:
109 NOTREACHED(); 109 NOTREACHED();
110 break; 110 break;
111 } 111 }
112 } 112 }
113 113
114 void RtcDataChannelHandler::OnMessage(const webrtc::DataBuffer& buffer) { 114 void RtcDataChannelHandler::OnMessage(const webrtc::DataBuffer& buffer) {
115 if (!webkit_client_) { 115 if (!webkit_client_) {
116 LOG(ERROR) << "WebRTCDataChannelHandlerClient not set."; 116 LOG(ERROR) << "WebRTCDataChannelHandlerClient not set.";
117 return; 117 return;
118 } 118 }
119 119
120 if (buffer.binary) { 120 if (buffer.binary) {
121 webkit_client_->didReceiveRawData(buffer.data.data(), buffer.data.length()); 121 webkit_client_->didReceiveRawData(buffer.data.data(), buffer.data.length());
122 } else { 122 } else {
123 string16 utf16; 123 string16 utf16;
124 if (!UTF8ToUTF16(buffer.data.data(), buffer.data.length(), &utf16)) { 124 if (!UTF8ToUTF16(buffer.data.data(), buffer.data.length(), &utf16)) {
125 LOG(ERROR) << "Failed convert received data to UTF16"; 125 LOG(ERROR) << "Failed convert received data to UTF16";
126 return; 126 return;
127 } 127 }
128 webkit_client_->didReceiveStringData(utf16); 128 webkit_client_->didReceiveStringData(utf16);
129 } 129 }
130 } 130 }
131 131
132 } // namespace content 132 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_data_channel_handler.h ('k') | content/renderer/media/rtc_dtmf_sender_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698