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

Side by Side Diff: ppapi/proxy/websocket_resource.cc

Issue 11267034: Provide IPC mechanism for host-to-resource messaging (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: reuse existing dispatch_reply_message.h Created 8 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
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 "ppapi/proxy/websocket_resource.h" 5 #include "ppapi/proxy/websocket_resource.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "ppapi/c/pp_errors.h" 11 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/proxy/dispatch_reply_message.h"
12 #include "ppapi/proxy/ppapi_messages.h" 13 #include "ppapi/proxy/ppapi_messages.h"
13 #include "ppapi/shared_impl/ppapi_globals.h" 14 #include "ppapi/shared_impl/ppapi_globals.h"
14 #include "ppapi/shared_impl/var.h" 15 #include "ppapi/shared_impl/var.h"
15 #include "ppapi/shared_impl/var_tracker.h" 16 #include "ppapi/shared_impl/var_tracker.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSocket.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSocket.h"
17 18
18 namespace { 19 namespace {
19 20
20 const uint32_t kMaxReasonSizeInBytes = 123; 21 const uint32_t kMaxReasonSizeInBytes = 123;
21 const size_t kBaseFramingOverhead = 2; 22 const size_t kBaseFramingOverhead = 2;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 323
323 PP_Var WebSocketResource::GetURL() { 324 PP_Var WebSocketResource::GetURL() {
324 if (!url_) 325 if (!url_)
325 return empty_string_->GetPPVar(); 326 return empty_string_->GetPPVar();
326 return url_->GetPPVar(); 327 return url_->GetPPVar();
327 } 328 }
328 329
329 void WebSocketResource::OnReplyReceived( 330 void WebSocketResource::OnReplyReceived(
330 const ResourceMessageReplyParams& params, 331 const ResourceMessageReplyParams& params,
331 const IPC::Message& msg) { 332 const IPC::Message& msg) {
332 if (params.sequence()) 333 if (params.sequence()) {
333 return PluginResource::OnReplyReceived(params, msg); 334 PluginResource::OnReplyReceived(params, msg);
335 return;
336 }
334 337
335 // TODO(toyoshim): Currently, following unsolicited reply IPCs are handled 338 IPC_BEGIN_MESSAGE_MAP(WebSocketResource, msg)
336 // manually. We should introduce more useful mechanism for that. 339 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
337 switch (msg.type()) { 340 PpapiPluginMsg_WebSocket_ReceiveTextReply,
338 case PpapiPluginMsg_WebSocket_ReceiveTextReply::ID: { 341 OnPluginMsgReceiveTextReply)
339 PpapiPluginMsg_WebSocket_ReceiveTextReply::Schema::Param p; 342 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
340 if (PpapiPluginMsg_WebSocket_ReceiveTextReply::Read(&msg, &p)) 343 PpapiPluginMsg_WebSocket_ReceiveBinaryReply,
341 OnPluginMsgReceiveTextReply(params, p.a); 344 OnPluginMsgReceiveBinaryReply)
342 else 345 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_0(
343 NOTREACHED(); 346 PpapiPluginMsg_WebSocket_ErrorReply,
344 break; 347 OnPluginMsgErrorReply)
345 } 348 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
346 case PpapiPluginMsg_WebSocket_ReceiveBinaryReply::ID: { 349 PpapiPluginMsg_WebSocket_BufferedAmountReply,
347 PpapiPluginMsg_WebSocket_ReceiveBinaryReply::Schema::Param p; 350 OnPluginMsgBufferedAmountReply)
348 if (PpapiPluginMsg_WebSocket_ReceiveBinaryReply::Read(&msg, &p)) 351 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
349 OnPluginMsgReceiveBinaryReply(params, p.a); 352 PpapiPluginMsg_WebSocket_StateReply,
350 else 353 OnPluginMsgStateReply)
351 NOTREACHED(); 354 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
352 break; 355 PpapiPluginMsg_WebSocket_ClosedReply,
353 } 356 OnPluginMsgClosedReply)
354 case PpapiPluginMsg_WebSocket_ErrorReply::ID: { 357 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(NOTREACHED())
355 OnPluginMsgErrorReply(params); 358 IPC_END_MESSAGE_MAP()
356 break;
357 }
358 case PpapiPluginMsg_WebSocket_BufferedAmountReply::ID: {
359 PpapiPluginMsg_WebSocket_BufferedAmountReply::Schema::Param p;
360 if (PpapiPluginMsg_WebSocket_BufferedAmountReply::Read(&msg, &p))
361 OnPluginMsgBufferedAmountReply(params, p.a);
362 else
363 NOTREACHED();
364 break;
365 }
366 case PpapiPluginMsg_WebSocket_StateReply::ID: {
367 PpapiPluginMsg_WebSocket_StateReply::Schema::Param p;
368 if (PpapiPluginMsg_WebSocket_StateReply::Read(&msg, &p))
369 OnPluginMsgStateReply(params, p.a);
370 else
371 NOTREACHED();
372 break;
373 }
374 case PpapiPluginMsg_WebSocket_ClosedReply::ID: {
375 PpapiPluginMsg_WebSocket_ClosedReply::Schema::Param p;
376 if (PpapiPluginMsg_WebSocket_ClosedReply::Read(&msg, &p))
377 OnPluginMsgClosedReply(params, p.a, p.b, p.c, p.d);
378 else
379 NOTREACHED();
380 break;
381 }
382 default:
383 NOTREACHED();
384 }
385 } 359 }
386 360
387 void WebSocketResource::OnPluginMsgConnectReply( 361 void WebSocketResource::OnPluginMsgConnectReply(
388 const ResourceMessageReplyParams& params, 362 const ResourceMessageReplyParams& params,
389 const std::string& url, 363 const std::string& url,
390 const std::string& protocol) { 364 const std::string& protocol) {
391 if (!TrackedCallback::IsPending(connect_callback_)) 365 if (!TrackedCallback::IsPending(connect_callback_))
392 return; 366 return;
393 367
394 int32_t result = params.result(); 368 int32_t result = params.result();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 return PP_OK; 474 return PP_OK;
501 475
502 *receive_callback_var_ = received_messages_.front()->GetPPVar(); 476 *receive_callback_var_ = received_messages_.front()->GetPPVar();
503 received_messages_.pop(); 477 received_messages_.pop();
504 receive_callback_var_ = NULL; 478 receive_callback_var_ = NULL;
505 return PP_OK; 479 return PP_OK;
506 } 480 }
507 481
508 } // namespace proxy 482 } // namespace proxy
509 } // namespace ppapi 483 } // namespace ppapi
OLDNEW
« ppapi/proxy/dispatch_reply_message.h ('K') | « ppapi/proxy/dispatch_reply_message.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698