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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_socket_utils.cc

Issue 2881673002: Avoid heap allocations in IPAddress (Closed)
Patch Set: Done 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) 2012 The Chromium Authors. All rights reserved. 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 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 #include "content/browser/renderer_host/pepper/pepper_socket_utils.h" 5 #include "content/browser/renderer_host/pepper/pepper_socket_utils.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/containers/stack_container.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "build/build_config.h" 16 #include "build/build_config.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/content_browser_client.h" 18 #include "content/public/browser/content_browser_client.h"
18 #include "content/public/browser/render_frame_host.h" 19 #include "content/public/browser/render_frame_host.h"
19 #include "content/public/browser/site_instance.h" 20 #include "content/public/browser/site_instance.h"
(...skipping 11 matching lines...) Expand all
31 32
32 namespace content { 33 namespace content {
33 namespace pepper_socket_utils { 34 namespace pepper_socket_utils {
34 35
35 SocketPermissionRequest CreateSocketPermissionRequest( 36 SocketPermissionRequest CreateSocketPermissionRequest(
36 SocketPermissionRequest::OperationType type, 37 SocketPermissionRequest::OperationType type,
37 const PP_NetAddress_Private& net_addr) { 38 const PP_NetAddress_Private& net_addr) {
38 std::string host = 39 std::string host =
39 ppapi::NetAddressPrivateImpl::DescribeNetAddress(net_addr, false); 40 ppapi::NetAddressPrivateImpl::DescribeNetAddress(net_addr, false);
40 uint16_t port = 0; 41 uint16_t port = 0;
41 std::vector<unsigned char> address; 42 base::StackVector<uint8_t, 16> address;
42 ppapi::NetAddressPrivateImpl::NetAddressToIPEndPoint( 43 ppapi::NetAddressPrivateImpl::NetAddressToIPEndPoint(
43 net_addr, &address, &port); 44 net_addr, &address, &port);
44 return SocketPermissionRequest(type, host, port); 45 return SocketPermissionRequest(type, host, port);
45 } 46 }
46 47
47 bool CanUseSocketAPIs(bool external_plugin, 48 bool CanUseSocketAPIs(bool external_plugin,
48 bool private_api, 49 bool private_api,
49 const SocketPermissionRequest* params, 50 const SocketPermissionRequest* params,
50 int render_process_id, 51 int render_process_id,
51 int render_frame_id) { 52 int render_frame_id) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 182 }
182 183
183 void OpenUDPFirewallHole(const net::IPEndPoint& address, 184 void OpenUDPFirewallHole(const net::IPEndPoint& address,
184 FirewallHoleOpenCallback callback) { 185 FirewallHoleOpenCallback callback) {
185 OpenFirewallHole(address, chromeos::FirewallHole::PortType::UDP, callback); 186 OpenFirewallHole(address, chromeos::FirewallHole::PortType::UDP, callback);
186 } 187 }
187 #endif // defined(OS_CHROMEOS) 188 #endif // defined(OS_CHROMEOS)
188 189
189 } // namespace pepper_socket_utils 190 } // namespace pepper_socket_utils
190 } // namespace content 191 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698