| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 const NPVariant* args, uint32 arg_count, | 177 const NPVariant* args, uint32 arg_count, |
| 178 NPVariant* result) { | 178 NPVariant* result) { |
| 179 if (!np_obj) | 179 if (!np_obj) |
| 180 return false; | 180 return false; |
| 181 | 181 |
| 182 // We only handle a function called postMessage. | 182 // We only handle a function called postMessage. |
| 183 if (IdentifierIsPostMessage(name) && (arg_count == 1)) { | 183 if (IdentifierIsPostMessage(name) && (arg_count == 1)) { |
| 184 MessageChannel& message_channel(ToMessageChannel(np_obj)); | 184 MessageChannel& message_channel(ToMessageChannel(np_obj)); |
| 185 PP_Var argument(NPVariantToPPVar(message_channel.instance(), &args[0])); | 185 PP_Var argument(NPVariantToPPVar(message_channel.instance(), &args[0])); |
| 186 message_channel.PostMessageToNative(argument); | 186 message_channel.PostMessageToNative(argument); |
| 187 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(argument); |
| 187 return true; | 188 return true; |
| 188 } | 189 } |
| 189 // Other method calls we will pass to the passthrough object, if we have one. | 190 // Other method calls we will pass to the passthrough object, if we have one. |
| 190 NPObject* passthrough = ToMessageChannel(np_obj).passthrough_object(); | 191 NPObject* passthrough = ToMessageChannel(np_obj).passthrough_object(); |
| 191 if (passthrough) { | 192 if (passthrough) { |
| 192 return WebBindings::invoke(NULL, passthrough, name, args, arg_count, | 193 return WebBindings::invoke(NULL, passthrough, name, args, arg_count, |
| 193 result); | 194 result); |
| 194 } | 195 } |
| 195 return false; | 196 return false; |
| 196 } | 197 } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 // SetPassthroughObject(passthrough_object()); | 414 // SetPassthroughObject(passthrough_object()); |
| 414 if (passthrough_object_) | 415 if (passthrough_object_) |
| 415 WebBindings::releaseObject(passthrough_object_); | 416 WebBindings::releaseObject(passthrough_object_); |
| 416 | 417 |
| 417 passthrough_object_ = passthrough; | 418 passthrough_object_ = passthrough; |
| 418 } | 419 } |
| 419 | 420 |
| 420 } // namespace ppapi | 421 } // namespace ppapi |
| 421 } // namespace webkit | 422 } // namespace webkit |
| 422 | 423 |
| OLD | NEW |