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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "extensions/browser/api/socket/udp_socket.h" | 8 #include "extensions/browser/api/socket/udp_socket.h" |
9 #include "extensions/browser/event_router.h" | 9 #include "extensions/browser/event_router.h" |
10 #include "extensions/browser/extensions_browser_client.h" | 10 #include "extensions/browser/extensions_browser_client.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 StartReceive(params); | 71 StartReceive(params); |
72 } | 72 } |
73 | 73 |
74 /* static */ | 74 /* static */ |
75 void UDPSocketEventDispatcher::StartReceive(const ReceiveParams& params) { | 75 void UDPSocketEventDispatcher::StartReceive(const ReceiveParams& params) { |
76 DCHECK_CURRENTLY_ON(params.thread_id); | 76 DCHECK_CURRENTLY_ON(params.thread_id); |
77 | 77 |
78 ResumableUDPSocket* socket = | 78 ResumableUDPSocket* socket = |
79 params.sockets->Get(params.extension_id, params.socket_id); | 79 params.sockets->Get(params.extension_id, params.socket_id); |
80 if (socket == NULL) { | 80 if (socket == nullptr) { |
81 // This can happen if the socket is closed while our callback is active. | 81 // This can happen if the socket is closed while our callback is active. |
82 return; | 82 return; |
83 } | 83 } |
84 DCHECK(params.extension_id == socket->owner_extension_id()) | 84 DCHECK(params.extension_id == socket->owner_extension_id()) |
85 << "Socket has wrong owner."; | 85 << "Socket has wrong owner."; |
86 | 86 |
87 // Don't start another read if the socket has been paused. | 87 // Don't start another read if the socket has been paused. |
88 if (socket->paused()) | 88 if (socket->paused()) |
89 return; | 89 return; |
90 | 90 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 reinterpret_cast<content::BrowserContext*>(browser_context_id); | 174 reinterpret_cast<content::BrowserContext*>(browser_context_id); |
175 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) | 175 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) |
176 return; | 176 return; |
177 EventRouter* router = EventRouter::Get(context); | 177 EventRouter* router = EventRouter::Get(context); |
178 if (router) | 178 if (router) |
179 router->DispatchEventToExtension(extension_id, event.Pass()); | 179 router->DispatchEventToExtension(extension_id, event.Pass()); |
180 } | 180 } |
181 | 181 |
182 } // namespace core_api | 182 } // namespace core_api |
183 } // namespace extensions | 183 } // namespace extensions |
OLD | NEW |