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

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

Issue 598173003: Run clang-modernize -use-nullptr over src/extensions/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 12 matching lines...) Expand all
23 template <> 23 template <>
24 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableUDPSocket> >* 24 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableUDPSocket> >*
25 ApiResourceManager<ResumableUDPSocket>::GetFactoryInstance() { 25 ApiResourceManager<ResumableUDPSocket>::GetFactoryInstance() {
26 return g_factory.Pointer(); 26 return g_factory.Pointer();
27 } 27 }
28 28
29 UDPSocket::UDPSocket(const std::string& owner_extension_id) 29 UDPSocket::UDPSocket(const std::string& owner_extension_id)
30 : Socket(owner_extension_id), 30 : Socket(owner_extension_id),
31 socket_(net::DatagramSocket::DEFAULT_BIND, 31 socket_(net::DatagramSocket::DEFAULT_BIND,
32 net::RandIntCallback(), 32 net::RandIntCallback(),
33 NULL, 33 nullptr,
34 net::NetLog::Source()) {} 34 net::NetLog::Source()) {
35 }
35 36
36 UDPSocket::~UDPSocket() { Disconnect(); } 37 UDPSocket::~UDPSocket() { Disconnect(); }
37 38
38 void UDPSocket::Connect(const std::string& address, 39 void UDPSocket::Connect(const std::string& address,
39 int port, 40 int port,
40 const CompletionCallback& callback) { 41 const CompletionCallback& callback) {
41 int result = net::ERR_CONNECTION_FAILED; 42 int result = net::ERR_CONNECTION_FAILED;
42 do { 43 do {
43 if (is_connected_) 44 if (is_connected_)
44 break; 45 break;
(...skipping 28 matching lines...) Expand all
73 read_callback_.Reset(); 74 read_callback_.Reset();
74 recv_from_callback_.Reset(); 75 recv_from_callback_.Reset();
75 send_to_callback_.Reset(); 76 send_to_callback_.Reset();
76 multicast_groups_.clear(); 77 multicast_groups_.clear();
77 } 78 }
78 79
79 void UDPSocket::Read(int count, const ReadCompletionCallback& callback) { 80 void UDPSocket::Read(int count, const ReadCompletionCallback& callback) {
80 DCHECK(!callback.is_null()); 81 DCHECK(!callback.is_null());
81 82
82 if (!read_callback_.is_null()) { 83 if (!read_callback_.is_null()) {
83 callback.Run(net::ERR_IO_PENDING, NULL); 84 callback.Run(net::ERR_IO_PENDING, nullptr);
84 return; 85 return;
85 } else { 86 } else {
86 read_callback_ = callback; 87 read_callback_ = callback;
87 } 88 }
88 89
89 int result = net::ERR_FAILED; 90 int result = net::ERR_FAILED;
90 scoped_refptr<net::IOBuffer> io_buffer; 91 scoped_refptr<net::IOBuffer> io_buffer;
91 do { 92 do {
92 if (count < 0) { 93 if (count < 0) {
93 result = net::ERR_INVALID_ARGUMENT; 94 result = net::ERR_INVALID_ARGUMENT;
(...skipping 24 matching lines...) Expand all
118 return net::ERR_SOCKET_NOT_CONNECTED; 119 return net::ERR_SOCKET_NOT_CONNECTED;
119 else 120 else
120 return socket_.Write(io_buffer, io_buffer_size, callback); 121 return socket_.Write(io_buffer, io_buffer_size, callback);
121 } 122 }
122 123
123 void UDPSocket::RecvFrom(int count, 124 void UDPSocket::RecvFrom(int count,
124 const RecvFromCompletionCallback& callback) { 125 const RecvFromCompletionCallback& callback) {
125 DCHECK(!callback.is_null()); 126 DCHECK(!callback.is_null());
126 127
127 if (!recv_from_callback_.is_null()) { 128 if (!recv_from_callback_.is_null()) {
128 callback.Run(net::ERR_IO_PENDING, NULL, std::string(), 0); 129 callback.Run(net::ERR_IO_PENDING, nullptr, std::string(), 0);
129 return; 130 return;
130 } else { 131 } else {
131 recv_from_callback_ = callback; 132 recv_from_callback_ = callback;
132 } 133 }
133 134
134 int result = net::ERR_FAILED; 135 int result = net::ERR_FAILED;
135 scoped_refptr<net::IOBuffer> io_buffer; 136 scoped_refptr<net::IOBuffer> io_buffer;
136 scoped_refptr<IPEndPoint> address; 137 scoped_refptr<IPEndPoint> address;
137 do { 138 do {
138 if (count < 0) { 139 if (count < 0) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 289
289 ResumableUDPSocket::ResumableUDPSocket(const std::string& owner_extension_id) 290 ResumableUDPSocket::ResumableUDPSocket(const std::string& owner_extension_id)
290 : UDPSocket(owner_extension_id), 291 : UDPSocket(owner_extension_id),
291 persistent_(false), 292 persistent_(false),
292 buffer_size_(0), 293 buffer_size_(0),
293 paused_(false) {} 294 paused_(false) {}
294 295
295 bool ResumableUDPSocket::IsPersistent() const { return persistent(); } 296 bool ResumableUDPSocket::IsPersistent() const { return persistent(); }
296 297
297 } // namespace extensions 298 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698