Chromium Code Reviews| 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 "ppapi/proxy/ppb_core_proxy.h" | 5 #include "ppapi/proxy/ppb_core_proxy.h" |
| 6 | 6 |
| 7 #include <stdlib.h> // For malloc | 7 #include <stdlib.h> // For malloc |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 DCHECK(callback.func); | 56 DCHECK(callback.func); |
| 57 #if defined(OS_NACL) | 57 #if defined(OS_NACL) |
| 58 // Some NaCl apps pass a negative delay, so we just sanitize to 0, to run as | 58 // Some NaCl apps pass a negative delay, so we just sanitize to 0, to run as |
| 59 // soon as possible. MessageLoop checks that the delay is non-negative. | 59 // soon as possible. MessageLoop checks that the delay is non-negative. |
| 60 if (delay_in_ms < 0) | 60 if (delay_in_ms < 0) |
| 61 delay_in_ms = 0; | 61 delay_in_ms = 0; |
| 62 #endif | 62 #endif |
| 63 if (!callback.func) | 63 if (!callback.func) |
| 64 return; | 64 return; |
| 65 ProxyAutoLock lock; | 65 ProxyAutoLock lock; |
| 66 | |
| 67 // If the plugin attempts to call CallOnMainThread from a background thread | |
| 68 // at shutdown, it's possible that the globals or the main loop has been | |
|
bbudge
2015/03/25 20:54:45
nit: s/has/have
dmichael (off chromium)
2015/03/25 21:33:06
I was treating both parts of the "or" as singular.
| |
| 69 // destroyed. | |
| 70 if (!PpapiGlobals::Get() || !PpapiGlobals::Get()->GetMainThreadMessageLoop()) | |
| 71 return; | |
| 72 | |
| 66 PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostDelayedTask( | 73 PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostDelayedTask( |
| 67 FROM_HERE, | 74 FROM_HERE, |
| 68 RunWhileLocked(base::Bind(&CallbackWrapper, callback, result)), | 75 RunWhileLocked(base::Bind(&CallbackWrapper, callback, result)), |
| 69 base::TimeDelta::FromMilliseconds(delay_in_ms)); | 76 base::TimeDelta::FromMilliseconds(delay_in_ms)); |
| 70 } | 77 } |
| 71 | 78 |
| 72 PP_Bool IsMainThread() { | 79 PP_Bool IsMainThread() { |
| 73 return PP_FromBool(PpapiGlobals::Get()-> | 80 return PP_FromBool(PpapiGlobals::Get()-> |
| 74 GetMainThreadMessageLoop()->BelongsToCurrentThread()); | 81 GetMainThreadMessageLoop()->BelongsToCurrentThread()); |
| 75 } | 82 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 ppb_core_impl_->AddRefResource(resource.host_resource()); | 131 ppb_core_impl_->AddRefResource(resource.host_resource()); |
| 125 } | 132 } |
| 126 | 133 |
| 127 void PPB_Core_Proxy::OnMsgReleaseResource(const HostResource& resource) { | 134 void PPB_Core_Proxy::OnMsgReleaseResource(const HostResource& resource) { |
| 128 ppb_core_impl_->ReleaseResource(resource.host_resource()); | 135 ppb_core_impl_->ReleaseResource(resource.host_resource()); |
| 129 } | 136 } |
| 130 #endif // !defined(OS_NACL) | 137 #endif // !defined(OS_NACL) |
| 131 | 138 |
| 132 } // namespace proxy | 139 } // namespace proxy |
| 133 } // namespace ppapi | 140 } // namespace ppapi |
| OLD | NEW |