Increase MessageAttachmentSet::kMaxDescriptorsPerMessage to 128
[chromium-blink-merge.git] / ppapi / cpp / message_loop.cc
blobdf3800737ddce4b53b5dfdb317315541fb3eb02f
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.
5 #include "ppapi/cpp/message_loop.h"
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_message_loop.h"
9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/instance_handle.h"
11 #include "ppapi/cpp/module_impl.h"
13 namespace pp {
15 namespace {
17 template <> const char* interface_name<PPB_MessageLoop>() {
18 return PPB_MESSAGELOOP_INTERFACE_1_0;
21 } // namespace
23 MessageLoop::MessageLoop() : Resource() {
26 MessageLoop::MessageLoop(const InstanceHandle& instance) : Resource() {
27 if (has_interface<PPB_MessageLoop>()) {
28 PassRefFromConstructor(get_interface<PPB_MessageLoop>()->Create(
29 instance.pp_instance()));
33 MessageLoop::MessageLoop(const MessageLoop& other)
34 : Resource(other) {
37 MessageLoop::MessageLoop(PP_Resource pp_message_loop)
38 : Resource(pp_message_loop) {
41 // static
42 MessageLoop MessageLoop::GetForMainThread() {
43 if (!has_interface<PPB_MessageLoop>())
44 return MessageLoop();
45 return MessageLoop(
46 get_interface<PPB_MessageLoop>()->GetForMainThread());
49 // static
50 MessageLoop MessageLoop::GetCurrent() {
51 if (!has_interface<PPB_MessageLoop>())
52 return MessageLoop();
53 return MessageLoop(
54 get_interface<PPB_MessageLoop>()->GetCurrent());
57 int32_t MessageLoop::AttachToCurrentThread() {
58 if (!has_interface<PPB_MessageLoop>())
59 return PP_ERROR_NOINTERFACE;
60 return get_interface<PPB_MessageLoop>()->AttachToCurrentThread(
61 pp_resource());
64 int32_t MessageLoop::Run() {
65 if (!has_interface<PPB_MessageLoop>())
66 return PP_ERROR_NOINTERFACE;
67 return get_interface<PPB_MessageLoop>()->Run(pp_resource());
70 int32_t MessageLoop::PostWork(const CompletionCallback& callback,
71 int64_t delay_ms) {
72 if (!has_interface<PPB_MessageLoop>())
73 return PP_ERROR_NOINTERFACE;
74 return get_interface<PPB_MessageLoop>()->PostWork(
75 pp_resource(),
76 callback.pp_completion_callback(),
77 delay_ms);
80 int32_t MessageLoop::PostQuit(bool should_destroy) {
81 if (!has_interface<PPB_MessageLoop>())
82 return PP_ERROR_NOINTERFACE;
83 return get_interface<PPB_MessageLoop>()->PostQuit(
84 pp_resource(), PP_FromBool(should_destroy));
87 } // namespace pp