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

Side by Side Diff: chrome/browser/extensions/api/dial/dial_service.h

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_SERVICE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_SERVICE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_SERVICE_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
17 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
18 #include "net/base/ip_address.h" 18 #include "net/base/ip_address.h"
19 #include "net/log/net_log.h" 19 #include "net/log/net_log.h"
20 #include "net/udp/udp_socket.h" 20 #include "net/udp/udp_socket.h"
21 21
22 namespace net { 22 namespace net {
23 class IPEndPoint; 23 class IPEndPoint;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 void HandleResponse(int bytes_read); 160 void HandleResponse(int bytes_read);
161 161
162 // Parses a response into a DialDeviceData object. If the DIAL response is 162 // Parses a response into a DialDeviceData object. If the DIAL response is
163 // invalid or does not contain enough information, then the return 163 // invalid or does not contain enough information, then the return
164 // value will be false and |device| is not changed. 164 // value will be false and |device| is not changed.
165 static bool ParseResponse(const std::string& response, 165 static bool ParseResponse(const std::string& response,
166 const base::Time& response_time, 166 const base::Time& response_time,
167 DialDeviceData* device); 167 DialDeviceData* device);
168 168
169 // The UDP socket. 169 // The UDP socket.
170 scoped_ptr<net::UDPSocket> socket_; 170 std::unique_ptr<net::UDPSocket> socket_;
171 171
172 // Buffer for socket reads. 172 // Buffer for socket reads.
173 scoped_refptr<net::IOBufferWithSize> recv_buffer_; 173 scoped_refptr<net::IOBufferWithSize> recv_buffer_;
174 174
175 // The source of of the last socket read. 175 // The source of of the last socket read.
176 net::IPEndPoint recv_address_; 176 net::IPEndPoint recv_address_;
177 177
178 // Thread checker. 178 // Thread checker.
179 base::ThreadChecker thread_checker_; 179 base::ThreadChecker thread_checker_;
180 180
(...skipping 30 matching lines...) Expand all
211 // |SendOneRequest()|, and start the timer to finish discovery if needed. 211 // |SendOneRequest()|, and start the timer to finish discovery if needed.
212 // The (Address family, interface index) of each address in |ip_addresses| 212 // The (Address family, interface index) of each address in |ip_addresses|
213 // must be unique. If |ip_address| is empty, calls |FinishDiscovery()|. 213 // must be unique. If |ip_address| is empty, calls |FinishDiscovery()|.
214 void DiscoverOnAddresses(const net::IPAddressList& ip_addresses); 214 void DiscoverOnAddresses(const net::IPAddressList& ip_addresses);
215 215
216 // Creates a DialSocket, binds it to |bind_ip_address| and if 216 // Creates a DialSocket, binds it to |bind_ip_address| and if
217 // successful, add the DialSocket to |dial_sockets_|. 217 // successful, add the DialSocket to |dial_sockets_|.
218 void BindAndAddSocket(const net::IPAddress& bind_ip_address); 218 void BindAndAddSocket(const net::IPAddress& bind_ip_address);
219 219
220 // Creates a DialSocket with callbacks to this object. 220 // Creates a DialSocket with callbacks to this object.
221 scoped_ptr<DialSocket> CreateDialSocket(); 221 std::unique_ptr<DialSocket> CreateDialSocket();
222 222
223 // Sends a single discovery request to every socket that are currently open. 223 // Sends a single discovery request to every socket that are currently open.
224 void SendOneRequest(); 224 void SendOneRequest();
225 225
226 // Notify observers that a discovery request was made. 226 // Notify observers that a discovery request was made.
227 void NotifyOnDiscoveryRequest(); 227 void NotifyOnDiscoveryRequest();
228 228
229 // Notify observers a device has been discovered. 229 // Notify observers a device has been discovered.
230 void NotifyOnDeviceDiscovered(const DialDeviceData& device_data); 230 void NotifyOnDeviceDiscovered(const DialDeviceData& device_data);
231 231
232 // Notify observers that there has been an error with one of the DialSockets. 232 // Notify observers that there has been an error with one of the DialSockets.
233 void NotifyOnError(); 233 void NotifyOnError();
234 234
235 // Called from finish_timer_ when we are done with the current round of 235 // Called from finish_timer_ when we are done with the current round of
236 // discovery. 236 // discovery.
237 void FinishDiscovery(); 237 void FinishDiscovery();
238 238
239 // Returns |true| if there are open sockets. 239 // Returns |true| if there are open sockets.
240 bool HasOpenSockets(); 240 bool HasOpenSockets();
241 241
242 // DialSockets for each network interface whose ip address was 242 // DialSockets for each network interface whose ip address was
243 // successfully bound. 243 // successfully bound.
244 std::vector<scoped_ptr<DialSocket>> dial_sockets_; 244 std::vector<std::unique_ptr<DialSocket>> dial_sockets_;
245 245
246 // The NetLog for this service. 246 // The NetLog for this service.
247 net::NetLog* net_log_; 247 net::NetLog* net_log_;
248 248
249 // The NetLog source for this service. 249 // The NetLog source for this service.
250 net::NetLog::Source net_log_source_; 250 net::NetLog::Source net_log_source_;
251 251
252 // The multicast address:port for search requests. 252 // The multicast address:port for search requests.
253 net::IPEndPoint send_address_; 253 net::IPEndPoint send_address_;
254 254
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDeviceDiscovered); 291 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDeviceDiscovered);
292 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDiscoveryFinished); 292 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDiscoveryFinished);
293 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDiscoveryRequest); 293 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDiscoveryRequest);
294 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestResponseParsing); 294 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestResponseParsing);
295 DISALLOW_COPY_AND_ASSIGN(DialServiceImpl); 295 DISALLOW_COPY_AND_ASSIGN(DialServiceImpl);
296 }; 296 };
297 297
298 } // namespace extensions 298 } // namespace extensions
299 299
300 #endif // CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_SERVICE_H_ 300 #endif // CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/dial/dial_registry_unittest.cc ('k') | chrome/browser/extensions/api/dial/dial_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698