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

Side by Side Diff: content/renderer/pepper/pepper_websocket_host.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/pepper/pepper_websocket_host.h" 5 #include "content/renderer/pepper/pepper_websocket_host.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "content/public/renderer/renderer_ppapi_host.h" 9 #include "content/public/renderer/renderer_ppapi_host.h"
10 #include "net/base/net_util.h" 10 #include "net/base/net_util.h"
11 #include "ppapi/c/pp_errors.h" 11 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/c/ppb_websocket.h" 12 #include "ppapi/c/ppb_websocket.h"
13 #include "ppapi/host/dispatch_host_message.h" 13 #include "ppapi/host/dispatch_host_message.h"
14 #include "ppapi/host/host_message_context.h" 14 #include "ppapi/host/host_message_context.h"
15 #include "ppapi/host/ppapi_host.h" 15 #include "ppapi/host/ppapi_host.h"
16 #include "ppapi/proxy/ppapi_messages.h" 16 #include "ppapi/proxy/ppapi_messages.h"
17 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" 17 #include "third_party/WebKit/public/platform/WebArrayBuffer.h"
18 #include "third_party/WebKit/public/platform/WebString.h" 18 #include "third_party/WebKit/public/platform/WebString.h"
19 #include "third_party/WebKit/public/platform/WebURL.h" 19 #include "third_party/WebKit/public/platform/WebURL.h"
20 #include "third_party/WebKit/public/web/WebDocument.h" 20 #include "third_party/WebKit/public/web/WebDocument.h"
21 #include "third_party/WebKit/public/web/WebElement.h" 21 #include "third_party/WebKit/public/web/WebElement.h"
22 #include "third_party/WebKit/public/web/WebPluginContainer.h" 22 #include "third_party/WebKit/public/web/WebPluginContainer.h"
23 #include "third_party/WebKit/public/web/WebSocket.h" 23 #include "third_party/WebKit/public/web/WebSocket.h"
24 24
25 using WebKit::WebArrayBuffer; 25 using blink::WebArrayBuffer;
26 using WebKit::WebDocument; 26 using blink::WebDocument;
27 using WebKit::WebString; 27 using blink::WebString;
28 using WebKit::WebSocket; 28 using blink::WebSocket;
29 using WebKit::WebURL; 29 using blink::WebURL;
30 30
31 namespace content { 31 namespace content {
32 32
33 PepperWebSocketHost::PepperWebSocketHost( 33 PepperWebSocketHost::PepperWebSocketHost(
34 RendererPpapiHost* host, 34 RendererPpapiHost* host,
35 PP_Instance instance, 35 PP_Instance instance,
36 PP_Resource resource) 36 PP_Resource resource)
37 : ResourceHost(host->GetPpapiHost(), instance, resource), 37 : ResourceHost(host->GetPpapiHost(), instance, resource),
38 renderer_ppapi_host_(host), 38 renderer_ppapi_host_(host),
39 connecting_(false), 39 connecting_(false),
(...skipping 30 matching lines...) Expand all
70 if (websocket_) 70 if (websocket_)
71 protocol = websocket_->subprotocol().utf8(); 71 protocol = websocket_->subprotocol().utf8();
72 connecting_ = false; 72 connecting_ = false;
73 connect_reply_.params.set_result(PP_OK); 73 connect_reply_.params.set_result(PP_OK);
74 host()->SendReply(connect_reply_, 74 host()->SendReply(connect_reply_,
75 PpapiPluginMsg_WebSocket_ConnectReply( 75 PpapiPluginMsg_WebSocket_ConnectReply(
76 url_, 76 url_,
77 protocol)); 77 protocol));
78 } 78 }
79 79
80 void PepperWebSocketHost::didReceiveMessage(const WebKit::WebString& message) { 80 void PepperWebSocketHost::didReceiveMessage(const blink::WebString& message) {
81 // Dispose packets after receiving an error. 81 // Dispose packets after receiving an error.
82 if (error_was_received_) 82 if (error_was_received_)
83 return; 83 return;
84 84
85 // Send an IPC to transport received data. 85 // Send an IPC to transport received data.
86 std::string string_message = message.utf8(); 86 std::string string_message = message.utf8();
87 host()->SendUnsolicitedReply(pp_resource(), 87 host()->SendUnsolicitedReply(pp_resource(),
88 PpapiPluginMsg_WebSocket_ReceiveTextReply( 88 PpapiPluginMsg_WebSocket_ReceiveTextReply(
89 string_message)); 89 string_message));
90 } 90 }
91 91
92 void PepperWebSocketHost::didReceiveArrayBuffer( 92 void PepperWebSocketHost::didReceiveArrayBuffer(
93 const WebKit::WebArrayBuffer& binaryData) { 93 const blink::WebArrayBuffer& binaryData) {
94 // Dispose packets after receiving an error. 94 // Dispose packets after receiving an error.
95 if (error_was_received_) 95 if (error_was_received_)
96 return; 96 return;
97 97
98 // Send an IPC to transport received data. 98 // Send an IPC to transport received data.
99 uint8_t* data = static_cast<uint8_t*>(binaryData.data()); 99 uint8_t* data = static_cast<uint8_t*>(binaryData.data());
100 std::vector<uint8_t> array_message(data, data + binaryData.byteLength()); 100 std::vector<uint8_t> array_message(data, data + binaryData.byteLength());
101 host()->SendUnsolicitedReply(pp_resource(), 101 host()->SendUnsolicitedReply(pp_resource(),
102 PpapiPluginMsg_WebSocket_ReceiveBinaryReply( 102 PpapiPluginMsg_WebSocket_ReceiveBinaryReply(
103 array_message)); 103 array_message));
(...skipping 24 matching lines...) Expand all
128 128
129 // Send an IPC to notice that server starts closing handshake. 129 // Send an IPC to notice that server starts closing handshake.
130 host()->SendUnsolicitedReply(pp_resource(), 130 host()->SendUnsolicitedReply(pp_resource(),
131 PpapiPluginMsg_WebSocket_StateReply( 131 PpapiPluginMsg_WebSocket_StateReply(
132 PP_WEBSOCKETREADYSTATE_CLOSING)); 132 PP_WEBSOCKETREADYSTATE_CLOSING));
133 } 133 }
134 134
135 void PepperWebSocketHost::didClose(unsigned long unhandled_buffered_amount, 135 void PepperWebSocketHost::didClose(unsigned long unhandled_buffered_amount,
136 ClosingHandshakeCompletionStatus status, 136 ClosingHandshakeCompletionStatus status,
137 unsigned short code, 137 unsigned short code,
138 const WebKit::WebString& reason) { 138 const blink::WebString& reason) {
139 if (connecting_) { 139 if (connecting_) {
140 connecting_ = false; 140 connecting_ = false;
141 connect_reply_.params.set_result(PP_ERROR_FAILED); 141 connect_reply_.params.set_result(PP_ERROR_FAILED);
142 host()->SendReply( 142 host()->SendReply(
143 connect_reply_, 143 connect_reply_,
144 PpapiPluginMsg_WebSocket_ConnectReply(url_, std::string())); 144 PpapiPluginMsg_WebSocket_ConnectReply(url_, std::string()));
145 } 145 }
146 146
147 // Set close_was_clean_. 147 // Set close_was_clean_.
148 bool was_clean = 148 bool was_clean =
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 217 }
218 // Join protocols with the comma separator. 218 // Join protocols with the comma separator.
219 if (vector_it != protocols.begin()) 219 if (vector_it != protocols.begin())
220 protocol_string.append(","); 220 protocol_string.append(",");
221 protocol_string.append(*vector_it); 221 protocol_string.append(*vector_it);
222 } 222 }
223 223
224 // Convert protocols to WebString. 224 // Convert protocols to WebString.
225 WebString web_protocols = WebString::fromUTF8(protocol_string); 225 WebString web_protocols = WebString::fromUTF8(protocol_string);
226 226
227 // Create WebKit::WebSocket object and connect. 227 // Create blink::WebSocket object and connect.
228 WebKit::WebPluginContainer* container = 228 blink::WebPluginContainer* container =
229 renderer_ppapi_host_->GetContainerForInstance(pp_instance()); 229 renderer_ppapi_host_->GetContainerForInstance(pp_instance());
230 if (!container) 230 if (!container)
231 return PP_ERROR_BADARGUMENT; 231 return PP_ERROR_BADARGUMENT;
232 // TODO(toyoshim) Remove following WebDocument object copy. 232 // TODO(toyoshim) Remove following WebDocument object copy.
233 WebDocument document = container->element().document(); 233 WebDocument document = container->element().document();
234 websocket_.reset(WebSocket::create(document, this)); 234 websocket_.reset(WebSocket::create(document, this));
235 DCHECK(websocket_.get()); 235 DCHECK(websocket_.get());
236 if (!websocket_) 236 if (!websocket_)
237 return PP_ERROR_NOTSUPPORTED; 237 return PP_ERROR_NOTSUPPORTED;
238 238
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 int32_t PepperWebSocketHost::OnHostMsgFail( 282 int32_t PepperWebSocketHost::OnHostMsgFail(
283 ppapi::host::HostMessageContext* context, 283 ppapi::host::HostMessageContext* context,
284 const std::string& message) { 284 const std::string& message) {
285 if (websocket_) 285 if (websocket_)
286 websocket_->fail(WebString::fromUTF8(message)); 286 websocket_->fail(WebString::fromUTF8(message));
287 return PP_OK; 287 return PP_OK;
288 } 288 }
289 289
290 } // namespace content 290 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_websocket_host.h ('k') | content/renderer/pepper/plugin_module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698