OLD | NEW |
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/sockets_udp/udp_socket_event_dispatcher.h" | 5 #include "extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "extensions/browser/api/socket/udp_socket.h" | 10 #include "extensions/browser/api/socket/udp_socket.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 buffer_size, | 95 buffer_size, |
96 base::Bind(&UDPSocketEventDispatcher::ReceiveCallback, params)); | 96 base::Bind(&UDPSocketEventDispatcher::ReceiveCallback, params)); |
97 } | 97 } |
98 | 98 |
99 /* static */ | 99 /* static */ |
100 void UDPSocketEventDispatcher::ReceiveCallback( | 100 void UDPSocketEventDispatcher::ReceiveCallback( |
101 const ReceiveParams& params, | 101 const ReceiveParams& params, |
102 int bytes_read, | 102 int bytes_read, |
103 scoped_refptr<net::IOBuffer> io_buffer, | 103 scoped_refptr<net::IOBuffer> io_buffer, |
104 const std::string& address, | 104 const std::string& address, |
105 uint16 port) { | 105 uint16_t port) { |
106 DCHECK_CURRENTLY_ON(params.thread_id); | 106 DCHECK_CURRENTLY_ON(params.thread_id); |
107 | 107 |
108 // If |bytes_read| == 0, the message contained no data. | 108 // If |bytes_read| == 0, the message contained no data. |
109 // If |bytes_read| < 0, there was a network error, and |bytes_read| is a value | 109 // If |bytes_read| < 0, there was a network error, and |bytes_read| is a value |
110 // from "net::ERR_". | 110 // from "net::ERR_". |
111 | 111 |
112 if (bytes_read >= 0) { | 112 if (bytes_read >= 0) { |
113 // Dispatch "onReceive" event. | 113 // Dispatch "onReceive" event. |
114 sockets_udp::ReceiveInfo receive_info; | 114 sockets_udp::ReceiveInfo receive_info; |
115 receive_info.socket_id = params.socket_id; | 115 receive_info.socket_id = params.socket_id; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 reinterpret_cast<content::BrowserContext*>(browser_context_id); | 176 reinterpret_cast<content::BrowserContext*>(browser_context_id); |
177 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) | 177 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) |
178 return; | 178 return; |
179 EventRouter* router = EventRouter::Get(context); | 179 EventRouter* router = EventRouter::Get(context); |
180 if (router) | 180 if (router) |
181 router->DispatchEventToExtension(extension_id, std::move(event)); | 181 router->DispatchEventToExtension(extension_id, std::move(event)); |
182 } | 182 } |
183 | 183 |
184 } // namespace api | 184 } // namespace api |
185 } // namespace extensions | 185 } // namespace extensions |
OLD | NEW |