Add an exponential backoff to rechecking the app list doodle.
[chromium-blink-merge.git] / ppapi / thunk / ppb_host_resolver_private_thunk.cc
blob9da6656497791c484669d15bc80e8ad9308092b0
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/c/pp_var.h"
6 #include "ppapi/c/private/ppb_host_resolver_private.h"
7 #include "ppapi/shared_impl/tracked_callback.h"
8 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/ppb_host_resolver_private_api.h"
10 #include "ppapi/thunk/resource_creation_api.h"
11 #include "ppapi/thunk/thunk.h"
13 namespace ppapi {
14 namespace thunk {
16 namespace {
18 typedef EnterResource<PPB_HostResolver_Private_API> EnterHostResolver;
20 PP_Resource Create(PP_Instance instance) {
21 EnterResourceCreation enter(instance);
22 if (enter.failed())
23 return 0;
24 return enter.functions()->CreateHostResolverPrivate(instance);
27 PP_Bool IsHostResolver(PP_Resource resource) {
28 EnterHostResolver enter(resource, false);
29 return PP_FromBool(enter.succeeded());
32 int32_t Resolve(PP_Resource host_resolver,
33 const char* host,
34 uint16_t port,
35 const PP_HostResolver_Private_Hint* hint,
36 PP_CompletionCallback callback) {
37 EnterHostResolver enter(host_resolver, callback, true);
38 if (enter.failed())
39 return enter.retval();
40 return enter.SetResult(enter.object()->Resolve(host, port, hint,
41 enter.callback()));
44 PP_Var GetCanonicalName(PP_Resource host_resolver) {
45 EnterHostResolver enter(host_resolver, true);
46 if (enter.failed())
47 return PP_MakeUndefined();
48 return enter.object()->GetCanonicalName();
51 uint32_t GetSize(PP_Resource host_resolver) {
52 EnterHostResolver enter(host_resolver, true);
53 if (enter.failed())
54 return 0;
55 return enter.object()->GetSize();
58 PP_Bool GetNetAddress(PP_Resource host_resolver,
59 uint32_t index,
60 PP_NetAddress_Private* addr) {
61 EnterHostResolver enter(host_resolver, true);
62 if (enter.failed())
63 return PP_FALSE;
64 return PP_FromBool(enter.object()->GetNetAddress(index, addr));
67 const PPB_HostResolver_Private g_ppb_host_resolver_thunk = {
68 &Create,
69 &IsHostResolver,
70 &Resolve,
71 &GetCanonicalName,
72 &GetSize,
73 &GetNetAddress
76 } // namespace
78 const PPB_HostResolver_Private_0_1* GetPPB_HostResolver_Private_0_1_Thunk() {
79 return &g_ppb_host_resolver_thunk;
82 } // namespace thunk
83 } // namespace ppapi