| OLD | NEW |
| 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" |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 MessageChannel::MessageChannelNPObject::~MessageChannelNPObject() {} | 317 MessageChannel::MessageChannelNPObject::~MessageChannelNPObject() {} |
| 318 | 318 |
| 319 MessageChannel::MessageChannel(PluginInstance* instance) | 319 MessageChannel::MessageChannel(PluginInstance* instance) |
| 320 : instance_(instance), | 320 : instance_(instance), |
| 321 passthrough_object_(NULL), | 321 passthrough_object_(NULL), |
| 322 np_object_(NULL), | 322 np_object_(NULL), |
| 323 weak_ptr_factory_(this), | 323 weak_ptr_factory_(this), |
| 324 early_message_queue_state_(QUEUE_MESSAGES) { | 324 early_message_queue_state_(QUEUE_MESSAGES) { |
| 325 // Now create an NPObject for receiving calls to postMessage. This sets the | 325 // Now create an NPObject for receiving calls to postMessage. This sets the |
| 326 // reference count to 1. We release it in the destructor. | 326 // reference count to 1. We release it in the destructor. |
| 327 NPObject* obj = WebBindings::createObject(instance_->instanceNPP(), | 327 NPObject* obj = WebBindings::createObject(NULL, &message_channel_class); |
| 328 &message_channel_class); | |
| 329 DCHECK(obj); | 328 DCHECK(obj); |
| 330 np_object_ = static_cast<MessageChannel::MessageChannelNPObject*>(obj); | 329 np_object_ = static_cast<MessageChannel::MessageChannelNPObject*>(obj); |
| 331 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); | 330 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); |
| 332 } | 331 } |
| 333 | 332 |
| 334 void MessageChannel::PostMessageToJavaScript(PP_Var message_data) { | 333 void MessageChannel::PostMessageToJavaScript(PP_Var message_data) { |
| 335 v8::HandleScope scope; | 334 v8::HandleScope scope; |
| 336 | 335 |
| 337 // Because V8 is probably not on the stack for Native->JS calls, we need to | 336 // Because V8 is probably not on the stack for Native->JS calls, we need to |
| 338 // enter the appropriate context for the plugin. | 337 // enter the appropriate context for the plugin. |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 // invokes: | 495 // invokes: |
| 497 // SetPassthroughObject(passthrough_object()); | 496 // SetPassthroughObject(passthrough_object()); |
| 498 if (passthrough_object_) | 497 if (passthrough_object_) |
| 499 WebBindings::releaseObject(passthrough_object_); | 498 WebBindings::releaseObject(passthrough_object_); |
| 500 | 499 |
| 501 passthrough_object_ = passthrough; | 500 passthrough_object_ = passthrough; |
| 502 } | 501 } |
| 503 | 502 |
| 504 } // namespace ppapi | 503 } // namespace ppapi |
| 505 } // namespace webkit | 504 } // namespace webkit |
| OLD | NEW |