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

Side by Side Diff: extensions/browser/api/socket/udp_socket.cc

Issue 1549643002: Switch to standard integer types in extensions/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clean
Patch Set: Created 4 years, 12 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/socket/udp_socket.h" 5 #include "extensions/browser/api/socket/udp_socket.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "extensions/browser/api/api_resource.h" 10 #include "extensions/browser/api/api_resource.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 if (result != net::OK) { 53 if (result != net::OK) {
54 socket_.Close(); 54 socket_.Close();
55 break; 55 break;
56 } 56 }
57 is_connected_ = true; 57 is_connected_ = true;
58 } while (false); 58 } while (false);
59 59
60 callback.Run(result); 60 callback.Run(result);
61 } 61 }
62 62
63 int UDPSocket::Bind(const std::string& address, uint16 port) { 63 int UDPSocket::Bind(const std::string& address, uint16_t port) {
64 if (IsBound()) 64 if (IsBound())
65 return net::ERR_CONNECTION_FAILED; 65 return net::ERR_CONNECTION_FAILED;
66 66
67 net::IPEndPoint ip_end_point; 67 net::IPEndPoint ip_end_point;
68 if (!StringAndPortToIPEndPoint(address, port, &ip_end_point)) 68 if (!StringAndPortToIPEndPoint(address, port, &ip_end_point))
69 return net::ERR_INVALID_ARGUMENT; 69 return net::ERR_INVALID_ARGUMENT;
70 70
71 int result = socket_.Open(ip_end_point.GetFamily()); 71 int result = socket_.Open(ip_end_point.GetFamily());
72 if (result != net::OK) 72 if (result != net::OK)
73 return result; 73 return result;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 DCHECK(!read_callback_.is_null()); 219 DCHECK(!read_callback_.is_null());
220 read_callback_.Run(result, io_buffer); 220 read_callback_.Run(result, io_buffer);
221 read_callback_.Reset(); 221 read_callback_.Reset();
222 } 222 }
223 223
224 void UDPSocket::OnRecvFromComplete(scoped_refptr<net::IOBuffer> io_buffer, 224 void UDPSocket::OnRecvFromComplete(scoped_refptr<net::IOBuffer> io_buffer,
225 scoped_refptr<IPEndPoint> address, 225 scoped_refptr<IPEndPoint> address,
226 int result) { 226 int result) {
227 DCHECK(!recv_from_callback_.is_null()); 227 DCHECK(!recv_from_callback_.is_null());
228 std::string ip; 228 std::string ip;
229 uint16 port = 0; 229 uint16_t port = 0;
230 if (result > 0 && address.get()) { 230 if (result > 0 && address.get()) {
231 IPEndPointToStringAndPort(address->data, &ip, &port); 231 IPEndPointToStringAndPort(address->data, &ip, &port);
232 } 232 }
233 recv_from_callback_.Run(result, io_buffer, ip, port); 233 recv_from_callback_.Run(result, io_buffer, ip, port);
234 recv_from_callback_.Reset(); 234 recv_from_callback_.Reset();
235 } 235 }
236 236
237 void UDPSocket::OnSendToComplete(int result) { 237 void UDPSocket::OnSendToComplete(int result) {
238 DCHECK(!send_to_callback_.is_null()); 238 DCHECK(!send_to_callback_.is_null());
239 send_to_callback_.Run(result); 239 send_to_callback_.Run(result);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 297
298 ResumableUDPSocket::ResumableUDPSocket(const std::string& owner_extension_id) 298 ResumableUDPSocket::ResumableUDPSocket(const std::string& owner_extension_id)
299 : UDPSocket(owner_extension_id), 299 : UDPSocket(owner_extension_id),
300 persistent_(false), 300 persistent_(false),
301 buffer_size_(0), 301 buffer_size_(0),
302 paused_(false) {} 302 paused_(false) {}
303 303
304 bool ResumableUDPSocket::IsPersistent() const { return persistent(); } 304 bool ResumableUDPSocket::IsPersistent() const { return persistent(); }
305 305
306 } // namespace extensions 306 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/socket/udp_socket.h ('k') | extensions/browser/api/sockets_tcp/sockets_tcp_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698