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
3// found in the LICENSE file.
4
5#include "remoting/client/plugin/pepper_plugin_thread_delegate.h"
6
7#include "ppapi/cpp/completion_callback.h"
8#include "ppapi/cpp/module.h"
9
10namespace remoting {
11
12PepperPluginThreadDelegate::PepperPluginThreadDelegate()
13    : core_(pp::Module::Get()->core()) {
14}
15
16PepperPluginThreadDelegate::~PepperPluginThreadDelegate() { }
17
18bool PepperPluginThreadDelegate::RunOnPluginThread(
19    base::TimeDelta delay, void(CDECL function)(void*), void* data) {
20  // It is safe to cast |function| to PP_CompletionCallback_Func,
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
23  // with VS when default calling convention is set to __stdcall, but
24  // this code will not typecheck in that case.
25  core_->CallOnMainThread(
26      delay.InMilliseconds(), pp::CompletionCallback(
27          reinterpret_cast<PP_CompletionCallback_Func>(function), data), 0);
28  return true;
29}
30
31}  // namespace remoting
32