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