1// Copyright 2014 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// From private/ppb_display_color_profile_private.idl,
6//   modified Tue Feb 18 18:03:36 2014.
7
8#include "ppapi/c/pp_completion_callback.h"
9#include "ppapi/c/pp_errors.h"
10#include "ppapi/c/private/ppb_display_color_profile_private.h"
11#include "ppapi/shared_impl/tracked_callback.h"
12#include "ppapi/thunk/enter.h"
13#include "ppapi/thunk/ppapi_thunk_export.h"
14#include "ppapi/thunk/ppb_display_color_profile_api.h"
15
16namespace ppapi {
17namespace thunk {
18
19namespace {
20
21PP_Resource Create(PP_Instance instance) {
22  VLOG(4) << "PPB_DisplayColorProfile_Private::Create()";
23  EnterResourceCreation enter(instance);
24  if (enter.failed())
25    return 0;
26  return enter.functions()->CreateDisplayColorProfilePrivate(instance);
27}
28
29PP_Bool IsDisplayColorProfile(PP_Resource resource) {
30  VLOG(4) << "PPB_DisplayColorProfile_Private::IsDisplayColorProfile()";
31  EnterResource<PPB_DisplayColorProfile_API> enter(resource, false);
32  return PP_FromBool(enter.succeeded());
33}
34
35int32_t GetColorProfile(PP_Resource display_color_profile_res,
36                        struct PP_ArrayOutput color_profile,
37                        struct PP_CompletionCallback callback) {
38  VLOG(4) << "PPB_DisplayColorProfile_Private::GetColorProfile()";
39  EnterResource<PPB_DisplayColorProfile_API> enter(display_color_profile_res,
40                                                   callback,
41                                                   true);
42  if (enter.failed())
43    return enter.retval();
44  return enter.SetResult(enter.object()->GetColorProfile(color_profile,
45                                                         enter.callback()));
46}
47
48int32_t RegisterColorProfileChangeCallback(
49    PP_Resource display_color_profile_res,
50    struct PP_CompletionCallback callback) {
51  VLOG(4) <<
52      "PPB_DisplayColorProfile_Private::RegisterColorProfileChangeCallback()";
53  EnterResource<PPB_DisplayColorProfile_API> enter(display_color_profile_res,
54                                                   callback,
55                                                   true);
56  if (enter.failed())
57    return enter.retval();
58  return enter.SetResult(enter.object()->RegisterColorProfileChangeCallback(
59      enter.callback()));
60}
61
62const PPB_DisplayColorProfile_Private_0_1
63    g_ppb_displaycolorprofile_private_thunk_0_1 = {
64  &Create,
65  &IsDisplayColorProfile,
66  &GetColorProfile,
67  &RegisterColorProfileChangeCallback
68};
69
70}  // namespace
71
72PPAPI_THUNK_EXPORT const PPB_DisplayColorProfile_Private_0_1*
73    GetPPB_DisplayColorProfile_Private_0_1_Thunk() {
74  return &g_ppb_displaycolorprofile_private_thunk_0_1;
75}
76
77}  // namespace thunk
78}  // namespace ppapi
79