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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "extensions/browser/api/socket/tcp_socket.h" | 10 #include "extensions/browser/api/socket/tcp_socket.h" |
11 #include "extensions/browser/event_router.h" | 11 #include "extensions/browser/event_router.h" |
12 #include "extensions/browser/extension_system.h" | 12 #include "extensions/browser/extension_system.h" |
13 #include "extensions/browser/extensions_browser_client.h" | 13 #include "extensions/browser/extensions_browser_client.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 int kDefaultBufferSize = 4096; | 17 int kDefaultBufferSize = 4096; |
18 } | 18 } |
19 | 19 |
20 namespace extensions { | 20 namespace extensions { |
21 namespace api { | 21 namespace api { |
22 | 22 |
23 using content::BrowserThread; | 23 using content::BrowserThread; |
24 | 24 |
25 static base::LazyInstance< | 25 static base::LazyInstance< |
26 BrowserContextKeyedAPIFactory<TCPSocketEventDispatcher> > g_factory = | 26 BrowserContextKeyedAPIFactory<TCPSocketEventDispatcher>>::DestructorAtExit |
27 LAZY_INSTANCE_INITIALIZER; | 27 g_factory = LAZY_INSTANCE_INITIALIZER; |
28 | 28 |
29 // static | 29 // static |
30 BrowserContextKeyedAPIFactory<TCPSocketEventDispatcher>* | 30 BrowserContextKeyedAPIFactory<TCPSocketEventDispatcher>* |
31 TCPSocketEventDispatcher::GetFactoryInstance() { | 31 TCPSocketEventDispatcher::GetFactoryInstance() { |
32 return g_factory.Pointer(); | 32 return g_factory.Pointer(); |
33 } | 33 } |
34 | 34 |
35 // static | 35 // static |
36 TCPSocketEventDispatcher* TCPSocketEventDispatcher::Get( | 36 TCPSocketEventDispatcher* TCPSocketEventDispatcher::Get( |
37 content::BrowserContext* context) { | 37 content::BrowserContext* context) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) | 198 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) |
199 return; | 199 return; |
200 | 200 |
201 EventRouter* event_router = EventRouter::Get(context); | 201 EventRouter* event_router = EventRouter::Get(context); |
202 if (event_router) | 202 if (event_router) |
203 event_router->DispatchEventToExtension(extension_id, std::move(event)); | 203 event_router->DispatchEventToExtension(extension_id, std::move(event)); |
204 } | 204 } |
205 | 205 |
206 } // namespace api | 206 } // namespace api |
207 } // namespace extensions | 207 } // namespace extensions |
OLD | NEW |