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

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

Issue 2333923004: Extracting NetLog inner classes into their own classes. (Closed)
Patch Set: Some nit fixes and better, impl-agnostic naming of net_log_parameters_callback_typedef.h -> net/log… Created 4 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/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "extensions/browser/api/api_resource.h" 11 #include "extensions/browser/api/api_resource.h"
12 #include "net/base/ip_address.h" 12 #include "net/base/ip_address.h"
13 #include "net/base/ip_endpoint.h" 13 #include "net/base/ip_endpoint.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/log/net_log_source.h"
15 #include "net/udp/datagram_socket.h" 16 #include "net/udp/datagram_socket.h"
16 #include "net/udp/udp_client_socket.h" 17 #include "net/udp/udp_client_socket.h"
17 18
18 namespace extensions { 19 namespace extensions {
19 20
20 static base::LazyInstance< 21 static base::LazyInstance<
21 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableUDPSocket> > > 22 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableUDPSocket> > >
22 g_factory = LAZY_INSTANCE_INITIALIZER; 23 g_factory = LAZY_INSTANCE_INITIALIZER;
23 24
24 // static 25 // static
25 template <> 26 template <>
26 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableUDPSocket> >* 27 BrowserContextKeyedAPIFactory<ApiResourceManager<ResumableUDPSocket> >*
27 ApiResourceManager<ResumableUDPSocket>::GetFactoryInstance() { 28 ApiResourceManager<ResumableUDPSocket>::GetFactoryInstance() {
28 return g_factory.Pointer(); 29 return g_factory.Pointer();
29 } 30 }
30 31
31 UDPSocket::UDPSocket(const std::string& owner_extension_id) 32 UDPSocket::UDPSocket(const std::string& owner_extension_id)
32 : Socket(owner_extension_id), 33 : Socket(owner_extension_id),
33 socket_(net::DatagramSocket::DEFAULT_BIND, 34 socket_(net::DatagramSocket::DEFAULT_BIND,
34 net::RandIntCallback(), 35 net::RandIntCallback(),
35 NULL, 36 NULL,
36 net::NetLog::Source()) {} 37 net::NetLogSource()) {}
37 38
38 UDPSocket::~UDPSocket() { Disconnect(); } 39 UDPSocket::~UDPSocket() { Disconnect(); }
39 40
40 void UDPSocket::Connect(const net::AddressList& address, 41 void UDPSocket::Connect(const net::AddressList& address,
41 const CompletionCallback& callback) { 42 const CompletionCallback& callback) {
42 int result = net::ERR_CONNECTION_FAILED; 43 int result = net::ERR_CONNECTION_FAILED;
43 do { 44 do {
44 if (is_connected_) 45 if (is_connected_)
45 break; 46 break;
46 47
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 304
304 ResumableUDPSocket::ResumableUDPSocket(const std::string& owner_extension_id) 305 ResumableUDPSocket::ResumableUDPSocket(const std::string& owner_extension_id)
305 : UDPSocket(owner_extension_id), 306 : UDPSocket(owner_extension_id),
306 persistent_(false), 307 persistent_(false),
307 buffer_size_(0), 308 buffer_size_(0),
308 paused_(false) {} 309 paused_(false) {}
309 310
310 bool ResumableUDPSocket::IsPersistent() const { return persistent(); } 311 bool ResumableUDPSocket::IsPersistent() const { return persistent(); }
311 312
312 } // namespace extensions 313 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698