| 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" |
| 11 #include "extensions/browser/event_router.h" | 11 #include "extensions/browser/event_router.h" |
| 12 #include "extensions/browser/extensions_browser_client.h" | 12 #include "extensions/browser/extensions_browser_client.h" |
| 13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 14 | 14 |
| 15 namespace extensions { | 15 namespace extensions { |
| 16 namespace api { | 16 namespace api { |
| 17 | 17 |
| 18 using content::BrowserThread; | 18 using content::BrowserThread; |
| 19 | 19 |
| 20 static base::LazyInstance< | 20 static base::LazyInstance< |
| 21 BrowserContextKeyedAPIFactory<UDPSocketEventDispatcher> > g_factory = | 21 BrowserContextKeyedAPIFactory<UDPSocketEventDispatcher>>::DestructorAtExit |
| 22 LAZY_INSTANCE_INITIALIZER; | 22 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 23 | 23 |
| 24 // static | 24 // static |
| 25 BrowserContextKeyedAPIFactory<UDPSocketEventDispatcher>* | 25 BrowserContextKeyedAPIFactory<UDPSocketEventDispatcher>* |
| 26 UDPSocketEventDispatcher::GetFactoryInstance() { | 26 UDPSocketEventDispatcher::GetFactoryInstance() { |
| 27 return g_factory.Pointer(); | 27 return g_factory.Pointer(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 UDPSocketEventDispatcher* UDPSocketEventDispatcher::Get( | 31 UDPSocketEventDispatcher* UDPSocketEventDispatcher::Get( |
| 32 content::BrowserContext* context) { | 32 content::BrowserContext* context) { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 reinterpret_cast<content::BrowserContext*>(browser_context_id); | 185 reinterpret_cast<content::BrowserContext*>(browser_context_id); |
| 186 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) | 186 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) |
| 187 return; | 187 return; |
| 188 EventRouter* router = EventRouter::Get(context); | 188 EventRouter* router = EventRouter::Get(context); |
| 189 if (router) | 189 if (router) |
| 190 router->DispatchEventToExtension(extension_id, std::move(event)); | 190 router->DispatchEventToExtension(extension_id, std::move(event)); |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace api | 193 } // namespace api |
| 194 } // namespace extensions | 194 } // namespace extensions |
| OLD | NEW |