| 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_tcp_server/tcp_server_socket_event_disp
atcher.h" | 5 #include "extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_disp
atcher.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "extensions/browser/api/socket/tcp_socket.h" | 8 #include "extensions/browser/api/socket/tcp_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" |
| 11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 namespace core_api { | 14 namespace api { |
| 15 | 15 |
| 16 using content::BrowserThread; | 16 using content::BrowserThread; |
| 17 | 17 |
| 18 static base::LazyInstance< | 18 static base::LazyInstance< |
| 19 BrowserContextKeyedAPIFactory<TCPServerSocketEventDispatcher> > g_factory = | 19 BrowserContextKeyedAPIFactory<TCPServerSocketEventDispatcher> > g_factory = |
| 20 LAZY_INSTANCE_INITIALIZER; | 20 LAZY_INSTANCE_INITIALIZER; |
| 21 | 21 |
| 22 // static | 22 // static |
| 23 BrowserContextKeyedAPIFactory<TCPServerSocketEventDispatcher>* | 23 BrowserContextKeyedAPIFactory<TCPServerSocketEventDispatcher>* |
| 24 TCPServerSocketEventDispatcher::GetFactoryInstance() { | 24 TCPServerSocketEventDispatcher::GetFactoryInstance() { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 190 |
| 191 content::BrowserContext* context = | 191 content::BrowserContext* context = |
| 192 reinterpret_cast<content::BrowserContext*>(browser_context_id); | 192 reinterpret_cast<content::BrowserContext*>(browser_context_id); |
| 193 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) | 193 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) |
| 194 return; | 194 return; |
| 195 EventRouter* router = EventRouter::Get(context); | 195 EventRouter* router = EventRouter::Get(context); |
| 196 if (router) | 196 if (router) |
| 197 router->DispatchEventToExtension(extension_id, event.Pass()); | 197 router->DispatchEventToExtension(extension_id, event.Pass()); |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace core_api | 200 } // namespace api |
| 201 } // namespace extensions | 201 } // namespace extensions |
| OLD | NEW |