| 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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 TRACE_EVENT2("ppapi proxy", "CallOnMainThread callback", | 47 TRACE_EVENT2("ppapi proxy", "CallOnMainThread callback", |
| 48 "Func", reinterpret_cast<void*>(callback.func), | 48 "Func", reinterpret_cast<void*>(callback.func), |
| 49 "UserData", callback.user_data); | 49 "UserData", callback.user_data); |
| 50 CallWhileUnlocked(PP_RunCompletionCallback, &callback, result); | 50 CallWhileUnlocked(PP_RunCompletionCallback, &callback, result); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void CallOnMainThread(int delay_in_ms, | 53 void CallOnMainThread(int delay_in_ms, |
| 54 PP_CompletionCallback callback, | 54 PP_CompletionCallback callback, |
| 55 int32_t result) { | 55 int32_t result) { |
| 56 DCHECK(callback.func); | 56 DCHECK(callback.func); |
| 57 #if defined(OS_NACL) |
| 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. |
| 60 if (delay_in_ms < 0) |
| 61 delay_in_ms = 0; |
| 62 #endif |
| 57 if (!callback.func) | 63 if (!callback.func) |
| 58 return; | 64 return; |
| 59 PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostDelayedTask( | 65 PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostDelayedTask( |
| 60 FROM_HERE, | 66 FROM_HERE, |
| 61 RunWhileLocked(base::Bind(&CallbackWrapper, callback, result)), | 67 RunWhileLocked(base::Bind(&CallbackWrapper, callback, result)), |
| 62 base::TimeDelta::FromMilliseconds(delay_in_ms)); | 68 base::TimeDelta::FromMilliseconds(delay_in_ms)); |
| 63 } | 69 } |
| 64 | 70 |
| 65 PP_Bool IsMainThread() { | 71 PP_Bool IsMainThread() { |
| 66 return PP_FromBool(PpapiGlobals::Get()-> | 72 return PP_FromBool(PpapiGlobals::Get()-> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 void PPB_Core_Proxy::OnMsgAddRefResource(const HostResource& resource) { | 117 void PPB_Core_Proxy::OnMsgAddRefResource(const HostResource& resource) { |
| 112 ppb_core_impl_->AddRefResource(resource.host_resource()); | 118 ppb_core_impl_->AddRefResource(resource.host_resource()); |
| 113 } | 119 } |
| 114 | 120 |
| 115 void PPB_Core_Proxy::OnMsgReleaseResource(const HostResource& resource) { | 121 void PPB_Core_Proxy::OnMsgReleaseResource(const HostResource& resource) { |
| 116 ppb_core_impl_->ReleaseResource(resource.host_resource()); | 122 ppb_core_impl_->ReleaseResource(resource.host_resource()); |
| 117 } | 123 } |
| 118 | 124 |
| 119 } // namespace proxy | 125 } // namespace proxy |
| 120 } // namespace ppapi | 126 } // namespace ppapi |
| OLD | NEW |