| 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 "remoting/client/plugin/pepper_plugin_thread_delegate.h" | 5 #include "remoting/client/plugin/pepper_plugin_thread_delegate.h" |
| 6 | 6 |
| 7 #include "ppapi/cpp/completion_callback.h" | 7 #include "ppapi/cpp/completion_callback.h" |
| 8 #include "ppapi/cpp/module.h" | 8 #include "ppapi/cpp/module.h" |
| 9 | 9 |
| 10 namespace remoting { | 10 namespace remoting { |
| 11 | 11 |
| 12 PepperPluginThreadDelegate::PepperPluginThreadDelegate() | 12 PepperPluginThreadDelegate::PepperPluginThreadDelegate() |
| 13 : core_(pp::Module::Get()->core()) { | 13 : core_(pp::Module::Get()->core()) { |
| 14 } | 14 } |
| 15 | 15 |
| 16 PepperPluginThreadDelegate::~PepperPluginThreadDelegate() { } | 16 PepperPluginThreadDelegate::~PepperPluginThreadDelegate() { } |
| 17 | 17 |
| 18 bool PepperPluginThreadDelegate::RunOnPluginThread( | 18 bool PepperPluginThreadDelegate::RunOnPluginThread( |
| 19 int delay_ms, void(CDECL function)(void*), void* data) { | 19 base::TimeDelta delay, void(CDECL function)(void*), void* data) { |
| 20 // It is safe to cast |function| to PP_CompletionCallback_Func, | 20 // It is safe to cast |function| to PP_CompletionCallback_Func, |
| 21 // which is defined as void(*)(void*, int). The callee will just | 21 // which is defined as void(*)(void*, int). The callee will just |
| 22 // ignore the last argument. The only case when it may be unsafe is | 22 // ignore the last argument. The only case when it may be unsafe is |
| 23 // with VS when default calling convention is set to __stdcall, but | 23 // with VS when default calling convention is set to __stdcall, but |
| 24 // this code will not typecheck in that case. | 24 // this code will not typecheck in that case. |
| 25 core_->CallOnMainThread( | 25 core_->CallOnMainThread( |
| 26 delay_ms, pp::CompletionCallback( | 26 delay.InMilliseconds(), pp::CompletionCallback( |
| 27 reinterpret_cast<PP_CompletionCallback_Func>(function), data), 0); | 27 reinterpret_cast<PP_CompletionCallback_Func>(function), data), 0); |
| 28 return true; | 28 return true; |
| 29 } | 29 } |
| 30 | 30 |
| 31 } // namespace remoting | 31 } // namespace remoting |
| OLD | NEW |