Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: ppapi/thunk/ppb_host_resolver_private_thunk.cc

Issue 9455092: HostResolver is exposed to plugin. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: s/class HostPortPair/struct HostPortPair. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 "ppapi/c/private/ppb_host_resolver_private.h"
6 #include "ppapi/thunk/enter.h"
7 #include "ppapi/thunk/ppb_host_resolver_private_api.h"
8 #include "ppapi/thunk/resource_creation_api.h"
9 #include "ppapi/thunk/thunk.h"
10
11 namespace ppapi {
12 namespace thunk {
13
14 namespace {
15
16 typedef EnterResource<PPB_HostResolver_Private_API> EnterHostResolver;
17
18 PP_Resource Create(PP_Instance instance) {
19 EnterFunction<ResourceCreationAPI> enter(instance, true);
20 if (enter.failed())
21 return 0;
22 return enter.functions()->CreateHostResolverPrivate(instance);
23 }
24
25 PP_Bool IsHostResolver(PP_Resource resource) {
26 EnterHostResolver enter(resource, false);
27 return PP_FromBool(enter.succeeded());
28 }
29
30 int32_t Resolve(PP_Resource host_resolver,
31 const char* host,
32 uint16_t port,
33 const PP_HostResolver_Private_Hint* hint,
34 PP_CompletionCallback callback) {
35 EnterHostResolver enter(host_resolver, callback, true);
36 if (enter.failed())
37 return enter.retval();
38 return enter.SetResult(enter.object()->Resolve(host, port, hint, callback));
39 }
40
41 uint32_t GetSize(PP_Resource host_resolver) {
42 EnterHostResolver enter(host_resolver, true);
43 if (enter.failed())
44 return 0;
45 return enter.object()->GetSize();
46 }
47
48 PP_Bool GetItem(PP_Resource host_resolver,
49 uint32_t index,
50 PP_Var* canonname,
51 PP_NetAddress_Private* addr) {
52 EnterHostResolver enter(host_resolver, true);
53 if (enter.failed())
54 return PP_FALSE;
55 return PP_FromBool(enter.object()->GetItem(index, canonname, addr));
56 }
57
58 const PPB_HostResolver_Private g_ppb_host_resolver_thunk = {
59 &Create,
60 &IsHostResolver,
61 &Resolve,
62 &GetSize,
63 &GetItem
64 };
65
66 } // namespace
67
68 const PPB_HostResolver_Private_0_1* GetPPB_HostResolver_Private_0_1_Thunk() {
69 return &g_ppb_host_resolver_thunk;
70 }
71
72 } // namespace thunk
73 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698