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: webkit/plugins/ppapi/message_channel.cc

Issue 19744007: Create a public API around webkit::ppapi::PluginInstance and use it in chrome. After this, webkit/p… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 4 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 | 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 "webkit/plugins/ppapi/message_channel.h" 5 #include "webkit/plugins/ppapi/message_channel.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "ppapi/shared_impl/ppapi_globals.h" 13 #include "ppapi/shared_impl/ppapi_globals.h"
14 #include "ppapi/shared_impl/var.h" 14 #include "ppapi/shared_impl/var.h"
15 #include "ppapi/shared_impl/var_tracker.h" 15 #include "ppapi/shared_impl/var_tracker.h"
16 #include "third_party/WebKit/public/web/WebBindings.h" 16 #include "third_party/WebKit/public/web/WebBindings.h"
17 #include "third_party/WebKit/public/web/WebDocument.h" 17 #include "third_party/WebKit/public/web/WebDocument.h"
18 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" 18 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h"
19 #include "third_party/WebKit/public/web/WebElement.h" 19 #include "third_party/WebKit/public/web/WebElement.h"
20 #include "third_party/WebKit/public/web/WebFrame.h" 20 #include "third_party/WebKit/public/web/WebFrame.h"
21 #include "third_party/WebKit/public/web/WebNode.h" 21 #include "third_party/WebKit/public/web/WebNode.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/WebSerializedScriptValue.h" 23 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h"
24 #include "v8/include/v8.h" 24 #include "v8/include/v8.h"
25 #include "webkit/plugins/ppapi/host_array_buffer_var.h" 25 #include "webkit/plugins/ppapi/host_array_buffer_var.h"
26 #include "webkit/plugins/ppapi/npapi_glue.h" 26 #include "webkit/plugins/ppapi/npapi_glue.h"
27 #include "webkit/plugins/ppapi/plugin_module.h" 27 #include "webkit/plugins/ppapi/plugin_module.h"
28 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 28 #include "webkit/plugins/ppapi/ppapi_plugin_instance_impl.h"
29 #include "webkit/plugins/ppapi/v8_var_converter.h" 29 #include "webkit/plugins/ppapi/v8_var_converter.h"
30 30
31 using ppapi::ArrayBufferVar; 31 using ppapi::ArrayBufferVar;
32 using ppapi::PpapiGlobals; 32 using ppapi::PpapiGlobals;
33 using ppapi::StringVar; 33 using ppapi::StringVar;
34 using WebKit::WebBindings; 34 using WebKit::WebBindings;
35 using WebKit::WebElement; 35 using WebKit::WebElement;
36 using WebKit::WebDOMEvent; 36 using WebKit::WebDOMEvent;
37 using WebKit::WebDOMMessageEvent; 37 using WebKit::WebDOMMessageEvent;
38 using WebKit::WebPluginContainer; 38 using WebKit::WebPluginContainer;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 }; 321 };
322 322
323 } // namespace 323 } // namespace
324 324
325 // MessageChannel -------------------------------------------------------------- 325 // MessageChannel --------------------------------------------------------------
326 MessageChannel::MessageChannelNPObject::MessageChannelNPObject() { 326 MessageChannel::MessageChannelNPObject::MessageChannelNPObject() {
327 } 327 }
328 328
329 MessageChannel::MessageChannelNPObject::~MessageChannelNPObject() {} 329 MessageChannel::MessageChannelNPObject::~MessageChannelNPObject() {}
330 330
331 MessageChannel::MessageChannel(PluginInstance* instance) 331 MessageChannel::MessageChannel(PluginInstanceImpl* instance)
332 : instance_(instance), 332 : instance_(instance),
333 passthrough_object_(NULL), 333 passthrough_object_(NULL),
334 np_object_(NULL), 334 np_object_(NULL),
335 weak_ptr_factory_(this), 335 weak_ptr_factory_(this),
336 early_message_queue_state_(QUEUE_MESSAGES) { 336 early_message_queue_state_(QUEUE_MESSAGES) {
337 // Now create an NPObject for receiving calls to postMessage. This sets the 337 // Now create an NPObject for receiving calls to postMessage. This sets the
338 // reference count to 1. We release it in the destructor. 338 // reference count to 1. We release it in the destructor.
339 NPObject* obj = WebBindings::createObject(instance_->instanceNPP(), 339 NPObject* obj = WebBindings::createObject(instance_->instanceNPP(),
340 &message_channel_class); 340 &message_channel_class);
341 DCHECK(obj); 341 DCHECK(obj);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 if (early_message_queue_state_ == DRAIN_PENDING) 418 if (early_message_queue_state_ == DRAIN_PENDING)
419 early_message_queue_state_ = DRAIN_CANCELLED; 419 early_message_queue_state_ = DRAIN_CANCELLED;
420 else 420 else
421 early_message_queue_state_ = QUEUE_MESSAGES; 421 early_message_queue_state_ = QUEUE_MESSAGES;
422 } 422 }
423 423
424 void MessageChannel::DrainEarlyMessageQueue() { 424 void MessageChannel::DrainEarlyMessageQueue() {
425 // Take a reference on the PluginInstance. This is because JavaScript code 425 // Take a reference on the PluginInstance. This is because JavaScript code
426 // may delete the plugin, which would destroy the PluginInstance and its 426 // may delete the plugin, which would destroy the PluginInstance and its
427 // corresponding MessageChannel. 427 // corresponding MessageChannel.
428 scoped_refptr<PluginInstance> instance_ref(instance_); 428 scoped_refptr<PluginInstanceImpl> instance_ref(instance_);
429 429
430 if (early_message_queue_state_ == DRAIN_CANCELLED) { 430 if (early_message_queue_state_ == DRAIN_CANCELLED) {
431 early_message_queue_state_ = QUEUE_MESSAGES; 431 early_message_queue_state_ = QUEUE_MESSAGES;
432 return; 432 return;
433 } 433 }
434 DCHECK(early_message_queue_state_ == DRAIN_PENDING); 434 DCHECK(early_message_queue_state_ == DRAIN_PENDING);
435 435
436 while (!early_message_queue_.empty()) { 436 while (!early_message_queue_.empty()) {
437 PostMessageToJavaScriptImpl(early_message_queue_.front()); 437 PostMessageToJavaScriptImpl(early_message_queue_.front());
438 early_message_queue_.pop_front(); 438 early_message_queue_.pop_front();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 // invokes: 511 // invokes:
512 // SetPassthroughObject(passthrough_object()); 512 // SetPassthroughObject(passthrough_object());
513 if (passthrough_object_) 513 if (passthrough_object_)
514 WebBindings::releaseObject(passthrough_object_); 514 WebBindings::releaseObject(passthrough_object_);
515 515
516 passthrough_object_ = passthrough; 516 passthrough_object_ = passthrough;
517 } 517 }
518 518
519 } // namespace ppapi 519 } // namespace ppapi
520 } // namespace webkit 520 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698