| 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 405 |
| 406 MessageChannel::~MessageChannel() { | 406 MessageChannel::~MessageChannel() { |
| 407 WebBindings::releaseObject(np_object_); | 407 WebBindings::releaseObject(np_object_); |
| 408 if (passthrough_object_) | 408 if (passthrough_object_) |
| 409 WebBindings::releaseObject(passthrough_object_); | 409 WebBindings::releaseObject(passthrough_object_); |
| 410 } | 410 } |
| 411 | 411 |
| 412 void MessageChannel::SetPassthroughObject(NPObject* passthrough) { | 412 void MessageChannel::SetPassthroughObject(NPObject* passthrough) { |
| 413 // Retain the passthrough object; We need to ensure it lives as long as this | 413 // Retain the passthrough object; We need to ensure it lives as long as this |
| 414 // MessageChannel. | 414 // MessageChannel. |
| 415 WebBindings::retainObject(passthrough); | 415 if (passthrough) |
| 416 WebBindings::retainObject(passthrough); |
| 416 | 417 |
| 417 // If we had a passthrough set already, release it. Note that we retain the | 418 // If we had a passthrough set already, release it. Note that we retain the |
| 418 // incoming passthrough object first, so that we behave correctly if anyone | 419 // incoming passthrough object first, so that we behave correctly if anyone |
| 419 // invokes: | 420 // invokes: |
| 420 // SetPassthroughObject(passthrough_object()); | 421 // SetPassthroughObject(passthrough_object()); |
| 421 if (passthrough_object_) | 422 if (passthrough_object_) |
| 422 WebBindings::releaseObject(passthrough_object_); | 423 WebBindings::releaseObject(passthrough_object_); |
| 423 | 424 |
| 424 passthrough_object_ = passthrough; | 425 passthrough_object_ = passthrough; |
| 425 } | 426 } |
| 426 | 427 |
| 427 } // namespace ppapi | 428 } // namespace ppapi |
| 428 } // namespace webkit | 429 } // namespace webkit |
| OLD | NEW |