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

Side by Side Diff: content/renderer/pepper/pepper_websocket_host.cc

Issue 1759263002: Rename public/web/WebSocket things to WebPepperSocket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more missed names. Created 4 years, 9 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 (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/port_util.h" 10 #include "net/base/port_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/WebString.h" 17 #include "third_party/WebKit/public/platform/WebString.h"
18 #include "third_party/WebKit/public/platform/WebURL.h" 18 #include "third_party/WebKit/public/platform/WebURL.h"
19 #include "third_party/WebKit/public/web/WebArrayBuffer.h" 19 #include "third_party/WebKit/public/web/WebArrayBuffer.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/WebPepperSocket.h"
22 #include "third_party/WebKit/public/web/WebPluginContainer.h" 23 #include "third_party/WebKit/public/web/WebPluginContainer.h"
23 #include "third_party/WebKit/public/web/WebSocket.h"
24 24
25 using blink::WebArrayBuffer; 25 using blink::WebArrayBuffer;
26 using blink::WebDocument; 26 using blink::WebDocument;
27 using blink::WebString; 27 using blink::WebString;
28 using blink::WebSocket; 28 using blink::WebPepperSocket;
29 using blink::WebURL; 29 using blink::WebURL;
30 30
31 namespace content { 31 namespace content {
32 32
33 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ 33 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \
34 static_assert( \ 34 static_assert(static_cast<int>(WebPepperSocket::webkit_name) == \
35 static_cast<int>(WebSocket::webkit_name) == static_cast<int>(np_name), \ 35 static_cast<int>(np_name), \
36 "WebSocket enums must match PPAPI's") 36 "WebSocket enums must match PPAPI's")
37 37
38 COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeNormalClosure, 38 COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeNormalClosure,
39 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE); 39 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE);
40 COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeGoingAway, 40 COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeGoingAway,
41 PP_WEBSOCKETSTATUSCODE_GOING_AWAY); 41 PP_WEBSOCKETSTATUSCODE_GOING_AWAY);
42 COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeProtocolError, 42 COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeProtocolError,
43 PP_WEBSOCKETSTATUSCODE_PROTOCOL_ERROR); 43 PP_WEBSOCKETSTATUSCODE_PROTOCOL_ERROR);
44 COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeUnsupportedData, 44 COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeUnsupportedData,
45 PP_WEBSOCKETSTATUSCODE_UNSUPPORTED_DATA); 45 PP_WEBSOCKETSTATUSCODE_UNSUPPORTED_DATA);
46 COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeNoStatusRcvd, 46 COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeNoStatusRcvd,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 connecting_ = false; 169 connecting_ = false;
170 connect_reply_.params.set_result(PP_ERROR_FAILED); 170 connect_reply_.params.set_result(PP_ERROR_FAILED);
171 host()->SendReply( 171 host()->SendReply(
172 connect_reply_, 172 connect_reply_,
173 PpapiPluginMsg_WebSocket_ConnectReply(url_, std::string())); 173 PpapiPluginMsg_WebSocket_ConnectReply(url_, std::string()));
174 } 174 }
175 175
176 // Set close_was_clean_. 176 // Set close_was_clean_.
177 bool was_clean = (initiating_close_ || accepting_close_) && 177 bool was_clean = (initiating_close_ || accepting_close_) &&
178 !unhandled_buffered_amount && 178 !unhandled_buffered_amount &&
179 status == WebSocketClient::ClosingHandshakeComplete; 179 status == WebPepperSocketClient::ClosingHandshakeComplete;
180 180
181 if (initiating_close_) { 181 if (initiating_close_) {
182 initiating_close_ = false; 182 initiating_close_ = false;
183 close_reply_.params.set_result(PP_OK); 183 close_reply_.params.set_result(PP_OK);
184 host()->SendReply( 184 host()->SendReply(
185 close_reply_, 185 close_reply_,
186 PpapiPluginMsg_WebSocket_CloseReply( 186 PpapiPluginMsg_WebSocket_CloseReply(
187 unhandled_buffered_amount, was_clean, code, reason.utf8())); 187 unhandled_buffered_amount, was_clean, code, reason.utf8()));
188 } else { 188 } else {
189 accepting_close_ = false; 189 accepting_close_ = false;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // Convert protocols to WebString. 252 // Convert protocols to WebString.
253 WebString web_protocols = WebString::fromUTF8(protocol_string); 253 WebString web_protocols = WebString::fromUTF8(protocol_string);
254 254
255 // Create blink::WebSocket object and connect. 255 // Create blink::WebSocket object and connect.
256 blink::WebPluginContainer* container = 256 blink::WebPluginContainer* container =
257 renderer_ppapi_host_->GetContainerForInstance(pp_instance()); 257 renderer_ppapi_host_->GetContainerForInstance(pp_instance());
258 if (!container) 258 if (!container)
259 return PP_ERROR_BADARGUMENT; 259 return PP_ERROR_BADARGUMENT;
260 // TODO(toyoshim) Remove following WebDocument object copy. 260 // TODO(toyoshim) Remove following WebDocument object copy.
261 WebDocument document = container->element().document(); 261 WebDocument document = container->element().document();
262 websocket_.reset(WebSocket::create(document, this)); 262 websocket_.reset(WebPepperSocket::create(document, this));
263 DCHECK(websocket_.get()); 263 DCHECK(websocket_.get());
264 if (!websocket_) 264 if (!websocket_)
265 return PP_ERROR_NOTSUPPORTED; 265 return PP_ERROR_NOTSUPPORTED;
266 266
267 // Set receiving binary object type. 267 // Set receiving binary object type.
268 websocket_->setBinaryType(WebSocket::BinaryTypeArrayBuffer); 268 websocket_->setBinaryType(WebPepperSocket::BinaryTypeArrayBuffer);
269 websocket_->connect(web_url, web_protocols); 269 websocket_->connect(web_url, web_protocols);
270 270
271 connect_reply_ = context->MakeReplyMessageContext(); 271 connect_reply_ = context->MakeReplyMessageContext();
272 connecting_ = true; 272 connecting_ = true;
273 return PP_OK_COMPLETIONPENDING; 273 return PP_OK_COMPLETIONPENDING;
274 } 274 }
275 275
276 int32_t PepperWebSocketHost::OnHostMsgClose( 276 int32_t PepperWebSocketHost::OnHostMsgClose(
277 ppapi::host::HostMessageContext* context, 277 ppapi::host::HostMessageContext* context,
278 int32_t code, 278 int32_t code,
279 const std::string& reason) { 279 const std::string& reason) {
280 if (!websocket_) 280 if (!websocket_)
281 return PP_ERROR_FAILED; 281 return PP_ERROR_FAILED;
282 close_reply_ = context->MakeReplyMessageContext(); 282 close_reply_ = context->MakeReplyMessageContext();
283 initiating_close_ = true; 283 initiating_close_ = true;
284 284
285 blink::WebSocket::CloseEventCode event_code = 285 blink::WebPepperSocket::CloseEventCode event_code =
286 static_cast<blink::WebSocket::CloseEventCode>(code); 286 static_cast<blink::WebPepperSocket::CloseEventCode>(code);
287 if (code == PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED) { 287 if (code == PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED) {
288 // PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED and CloseEventCodeNotSpecified are 288 // PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED and CloseEventCodeNotSpecified are
289 // assigned to different values. A conversion is needed if 289 // assigned to different values. A conversion is needed if
290 // PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED is specified. 290 // PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED is specified.
291 event_code = blink::WebSocket::CloseEventCodeNotSpecified; 291 event_code = blink::WebPepperSocket::CloseEventCodeNotSpecified;
292 } 292 }
293 293
294 WebString web_reason = WebString::fromUTF8(reason); 294 WebString web_reason = WebString::fromUTF8(reason);
295 websocket_->close(event_code, web_reason); 295 websocket_->close(event_code, web_reason);
296 return PP_OK_COMPLETIONPENDING; 296 return PP_OK_COMPLETIONPENDING;
297 } 297 }
298 298
299 int32_t PepperWebSocketHost::OnHostMsgSendText( 299 int32_t PepperWebSocketHost::OnHostMsgSendText(
300 ppapi::host::HostMessageContext* context, 300 ppapi::host::HostMessageContext* context,
301 const std::string& message) { 301 const std::string& message) {
(...skipping 17 matching lines...) Expand all
319 319
320 int32_t PepperWebSocketHost::OnHostMsgFail( 320 int32_t PepperWebSocketHost::OnHostMsgFail(
321 ppapi::host::HostMessageContext* context, 321 ppapi::host::HostMessageContext* context,
322 const std::string& message) { 322 const std::string& message) {
323 if (websocket_) 323 if (websocket_)
324 websocket_->fail(WebString::fromUTF8(message)); 324 websocket_->fail(WebString::fromUTF8(message));
325 return PP_OK; 325 return PP_OK;
326 } 326 }
327 327
328 } // namespace content 328 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_websocket_host.h ('k') | third_party/WebKit/Source/web/WebPepperSocket.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698