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(NULL, &message_channel_class); | 327 NPObject* obj = WebBindings::createObject(instance_->instanceNPP(), |
| 328 &message_channel_class); |
328 DCHECK(obj); | 329 DCHECK(obj); |
329 np_object_ = static_cast<MessageChannel::MessageChannelNPObject*>(obj); | 330 np_object_ = static_cast<MessageChannel::MessageChannelNPObject*>(obj); |
330 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); | 331 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); |
331 } | 332 } |
332 | 333 |
333 void MessageChannel::PostMessageToJavaScript(PP_Var message_data) { | 334 void MessageChannel::PostMessageToJavaScript(PP_Var message_data) { |
334 v8::HandleScope scope; | 335 v8::HandleScope scope; |
335 | 336 |
336 // Because V8 is probably not on the stack for Native->JS calls, we need to | 337 // Because V8 is probably not on the stack for Native->JS calls, we need to |
337 // enter the appropriate context for the plugin. | 338 // enter the appropriate context for the plugin. |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 // invokes: | 496 // invokes: |
496 // SetPassthroughObject(passthrough_object()); | 497 // SetPassthroughObject(passthrough_object()); |
497 if (passthrough_object_) | 498 if (passthrough_object_) |
498 WebBindings::releaseObject(passthrough_object_); | 499 WebBindings::releaseObject(passthrough_object_); |
499 | 500 |
500 passthrough_object_ = passthrough; | 501 passthrough_object_ = passthrough; |
501 } | 502 } |
502 | 503 |
503 } // namespace ppapi | 504 } // namespace ppapi |
504 } // namespace webkit | 505 } // namespace webkit |
OLD | NEW |