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/tcp_socket_event_dispatcher.h" | 5 #include "extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.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/extension_system.h" | 10 #include "extensions/browser/extension_system.h" |
11 #include "extensions/browser/extensions_browser_client.h" | 11 #include "extensions/browser/extensions_browser_client.h" |
12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 int kDefaultBufferSize = 4096; | 15 int kDefaultBufferSize = 4096; |
16 } | 16 } |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 namespace core_api { | 19 namespace api { |
20 | 20 |
21 using content::BrowserThread; | 21 using content::BrowserThread; |
22 | 22 |
23 static base::LazyInstance< | 23 static base::LazyInstance< |
24 BrowserContextKeyedAPIFactory<TCPSocketEventDispatcher> > g_factory = | 24 BrowserContextKeyedAPIFactory<TCPSocketEventDispatcher> > g_factory = |
25 LAZY_INSTANCE_INITIALIZER; | 25 LAZY_INSTANCE_INITIALIZER; |
26 | 26 |
27 // static | 27 // static |
28 BrowserContextKeyedAPIFactory<TCPSocketEventDispatcher>* | 28 BrowserContextKeyedAPIFactory<TCPSocketEventDispatcher>* |
29 TCPSocketEventDispatcher::GetFactoryInstance() { | 29 TCPSocketEventDispatcher::GetFactoryInstance() { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 content::BrowserContext* context = | 190 content::BrowserContext* context = |
191 reinterpret_cast<content::BrowserContext*>(browser_context_id); | 191 reinterpret_cast<content::BrowserContext*>(browser_context_id); |
192 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) | 192 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) |
193 return; | 193 return; |
194 | 194 |
195 EventRouter* event_router = EventRouter::Get(context); | 195 EventRouter* event_router = EventRouter::Get(context); |
196 if (event_router) | 196 if (event_router) |
197 event_router->DispatchEventToExtension(extension_id, event.Pass()); | 197 event_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 |