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

Side by Side Diff: ppapi/shared_impl/private/net_address_private_impl.h

Issue 2881673002: Avoid heap allocations in IPAddress (Closed)
Patch Set: Rename and Assign Created 3 years, 7 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ 5 #ifndef PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_
6 #define PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ 6 #define PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string> 9 #include <string>
10 #include <vector>
11 10
12 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "net/base/ip_address.h"
13 #include "ppapi/c/pp_stdint.h" 13 #include "ppapi/c/pp_stdint.h"
14 #include "ppapi/c/ppb_net_address.h" 14 #include "ppapi/c/ppb_net_address.h"
15 #include "ppapi/shared_impl/ppapi_shared_export.h" 15 #include "ppapi/shared_impl/ppapi_shared_export.h"
16 16
17 struct PP_NetAddress_Private; 17 struct PP_NetAddress_Private;
18 struct sockaddr; 18 struct sockaddr;
19 19
20 namespace ppapi { 20 namespace ppapi {
21 21
22 class PPAPI_SHARED_EXPORT NetAddressPrivateImpl { 22 class PPAPI_SHARED_EXPORT NetAddressPrivateImpl {
23 public: 23 public:
24 static bool ValidateNetAddress(const PP_NetAddress_Private& addr); 24 static bool ValidateNetAddress(const PP_NetAddress_Private& addr);
25 25
26 static bool SockaddrToNetAddress(const sockaddr* sa, 26 static bool SockaddrToNetAddress(const sockaddr* sa,
27 uint32_t sa_length, 27 uint32_t sa_length,
28 PP_NetAddress_Private* net_addr); 28 PP_NetAddress_Private* net_addr);
29 29
30 static bool IPEndPointToNetAddress(const std::vector<uint8_t>& address, 30 static bool IPEndPointToNetAddress(const net::IPAddressBytes& address,
31 uint16_t port, 31 uint16_t port,
32 PP_NetAddress_Private* net_addr); 32 PP_NetAddress_Private* net_addr);
33 33
34 static bool NetAddressToIPEndPoint(const PP_NetAddress_Private& net_addr, 34 static bool NetAddressToIPEndPoint(const PP_NetAddress_Private& net_addr,
35 std::vector<uint8_t>* address, 35 net::IPAddressBytes* address,
36 uint16_t* port); 36 uint16_t* port);
37 37
38 static std::string DescribeNetAddress(const PP_NetAddress_Private& addr, 38 static std::string DescribeNetAddress(const PP_NetAddress_Private& addr,
39 bool include_port); 39 bool include_port);
40 40
41 static void GetAnyAddress(PP_Bool is_ipv6, PP_NetAddress_Private* addr); 41 static void GetAnyAddress(PP_Bool is_ipv6, PP_NetAddress_Private* addr);
42 42
43 // Conversion methods to make PPB_NetAddress resource work with 43 // Conversion methods to make PPB_NetAddress resource work with
44 // PP_NetAddress_Private. 44 // PP_NetAddress_Private.
45 // TODO(yzshen): Remove them once PPB_NetAddress resource doesn't use 45 // TODO(yzshen): Remove them once PPB_NetAddress resource doesn't use
(...skipping 15 matching lines...) Expand all
61 61
62 static const PP_NetAddress_Private kInvalidNetAddress; 62 static const PP_NetAddress_Private kInvalidNetAddress;
63 63
64 private: 64 private:
65 DISALLOW_IMPLICIT_CONSTRUCTORS(NetAddressPrivateImpl); 65 DISALLOW_IMPLICIT_CONSTRUCTORS(NetAddressPrivateImpl);
66 }; 66 };
67 67
68 } // namespace ppapi 68 } // namespace ppapi
69 69
70 #endif // PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ 70 #endif // PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698