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

Side by Side Diff: ppapi/cpp/private/net_address_private.cc

Issue 8511032: Make the Pepper Flash net address just private, not Flash-specific. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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/cpp/private/net_address_private.h"
6
7 #include "ppapi/c/pp_bool.h"
8 #include "ppapi/cpp/module.h"
9 #include "ppapi/cpp/module_impl.h"
10 #include "ppapi/cpp/var.h"
11 #include "ppapi/c/private/ppb_net_address_private.h"
12
13 namespace pp {
14
15 namespace {
16
17 template <> const char* interface_name<PPB_NetAddress_Private>() {
18 return PPB_NETADDRESS_PRIVATE_INTERFACE;
19 }
20
21 } // namespace
22
23 // static
24 bool NetAddress::AreEqual(const PP_NetAddress_Private& addr1,
25 const PP_NetAddress_Private& addr2) {
26 if (!has_interface<PPB_NetAddress_Private>())
27 return false;
28 return !!get_interface<PPB_NetAddress_Private>()->AreEqual(&addr1, &addr2);
29 }
30
31 // static
32 bool NetAddress::AreHostsEqual(const PP_NetAddress_Private& addr1,
33 const PP_NetAddress_Private& addr2) {
34 if (!has_interface<PPB_NetAddress_Private>())
35 return false;
36 return !!get_interface<PPB_NetAddress_Private>()->AreHostsEqual(&addr1,
37 &addr2);
38 }
39
40 // static
41 std::string NetAddress::Describe(const PP_NetAddress_Private& addr,
42 bool include_port) {
43 if (!has_interface<PPB_NetAddress_Private>())
44 return std::string();
45
46 Module* module = Module::Get();
47 if (!module)
48 return std::string();
49
50 Var result(Var::PassRef(),
51 get_interface<PPB_NetAddress_Private>()->Describe(
52 module->pp_module(),
53 &addr,
54 PP_FromBool(include_port)));
55 return result.is_string() ? result.AsString() : std::string();
56 }
57
58 // static
59 bool NetAddress::ReplacePort(const PP_NetAddress_Private& addr_in,
60 uint16_t port,
61 PP_NetAddress_Private* addr_out) {
62 if (!has_interface<PPB_NetAddress_Private>())
63 return false;
64 return !!get_interface<PPB_NetAddress_Private>()->ReplacePort(&addr_in,
65 port,
66 addr_out);
67 }
68
69 // static
70 void NetAddress::GetAnyAddress(bool is_ipv6, PP_NetAddress_Private* addr) {
71 if (!has_interface<PPB_NetAddress_Private>())
72 return;
73 get_interface<PPB_NetAddress_Private>()->GetAnyAddress(PP_FromBool(is_ipv6),
74 addr);
75 }
76
77 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698