
The methodology used to generate this CL is documented in https://crbug.com/1098010#c95. No-Try: true Bug: 1098010 Change-Id: I6ae92e5d7ccbf73b176588124b2f8b4067f805b3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3900575 Reviewed-by: Mark Mentovai <mark@chromium.org> Owners-Override: Avi Drissman <avi@chromium.org> Commit-Queue: Avi Drissman <avi@chromium.org> Auto-Submit: Avi Drissman <avi@chromium.org> Cr-Commit-Position: refs/heads/main@{#1047628}
90 lines
2.4 KiB
C++
90 lines
2.4 KiB
C++
// Copyright 2012 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "ppapi/cpp/message_loop.h"
|
|
|
|
#include "ppapi/c/pp_errors.h"
|
|
#include "ppapi/c/ppb_message_loop.h"
|
|
#include "ppapi/cpp/completion_callback.h"
|
|
#include "ppapi/cpp/instance_handle.h"
|
|
#include "ppapi/cpp/module_impl.h"
|
|
|
|
namespace pp {
|
|
|
|
namespace {
|
|
|
|
template <> const char* interface_name<PPB_MessageLoop>() {
|
|
return PPB_MESSAGELOOP_INTERFACE_1_0;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
MessageLoop::MessageLoop() : Resource() {}
|
|
|
|
MessageLoop::MessageLoop(const InstanceHandle& instance) : Resource() {
|
|
if (has_interface<PPB_MessageLoop>()) {
|
|
PassRefFromConstructor(get_interface<PPB_MessageLoop>()->Create(
|
|
instance.pp_instance()));
|
|
}
|
|
}
|
|
|
|
MessageLoop::MessageLoop(const MessageLoop& other) : Resource(other) {}
|
|
|
|
MessageLoop& MessageLoop::operator=(const MessageLoop& other) {
|
|
Resource::operator=(other);
|
|
return *this;
|
|
}
|
|
|
|
MessageLoop::MessageLoop(PP_Resource pp_message_loop)
|
|
: Resource(pp_message_loop) {
|
|
}
|
|
|
|
// static
|
|
MessageLoop MessageLoop::GetForMainThread() {
|
|
if (!has_interface<PPB_MessageLoop>())
|
|
return MessageLoop();
|
|
return MessageLoop(
|
|
get_interface<PPB_MessageLoop>()->GetForMainThread());
|
|
}
|
|
|
|
// static
|
|
MessageLoop MessageLoop::GetCurrent() {
|
|
if (!has_interface<PPB_MessageLoop>())
|
|
return MessageLoop();
|
|
return MessageLoop(
|
|
get_interface<PPB_MessageLoop>()->GetCurrent());
|
|
}
|
|
|
|
int32_t MessageLoop::AttachToCurrentThread() {
|
|
if (!has_interface<PPB_MessageLoop>())
|
|
return PP_ERROR_NOINTERFACE;
|
|
return get_interface<PPB_MessageLoop>()->AttachToCurrentThread(
|
|
pp_resource());
|
|
}
|
|
|
|
int32_t MessageLoop::Run() {
|
|
if (!has_interface<PPB_MessageLoop>())
|
|
return PP_ERROR_NOINTERFACE;
|
|
return get_interface<PPB_MessageLoop>()->Run(pp_resource());
|
|
}
|
|
|
|
int32_t MessageLoop::PostWork(const CompletionCallback& callback,
|
|
int64_t delay_ms) {
|
|
if (!has_interface<PPB_MessageLoop>())
|
|
return PP_ERROR_NOINTERFACE;
|
|
return get_interface<PPB_MessageLoop>()->PostWork(
|
|
pp_resource(),
|
|
callback.pp_completion_callback(),
|
|
delay_ms);
|
|
}
|
|
|
|
int32_t MessageLoop::PostQuit(bool should_destroy) {
|
|
if (!has_interface<PPB_MessageLoop>())
|
|
return PP_ERROR_NOINTERFACE;
|
|
return get_interface<PPB_MessageLoop>()->PostQuit(
|
|
pp_resource(), PP_FromBool(should_destroy));
|
|
}
|
|
|
|
} // namespace pp
|