| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/extensions/api/sockets_udp/udp_socket_event_dispatcher.
h" | 5 #include "chrome/browser/extensions/api/sockets_udp/udp_socket_event_dispatcher.
h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/socket/udp_socket.h" | 7 #include "chrome/browser/extensions/api/socket/udp_socket.h" |
| 8 #include "extensions/browser/event_router.h" | 8 #include "extensions/browser/event_router.h" |
| 9 #include "extensions/browser/extension_system.h" | 9 #include "extensions/browser/extension_system.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 api { | 14 namespace api { |
| 15 | 15 |
| 16 using content::BrowserThread; | 16 using content::BrowserThread; |
| 17 | 17 |
| 18 static base::LazyInstance<ProfileKeyedAPIFactory<UDPSocketEventDispatcher> > | 18 static base::LazyInstance< |
| 19 g_factory = LAZY_INSTANCE_INITIALIZER; | 19 BrowserContextKeyedAPIFactory<UDPSocketEventDispatcher> > g_factory = |
| 20 LAZY_INSTANCE_INITIALIZER; |
| 20 | 21 |
| 21 // static | 22 // static |
| 22 ProfileKeyedAPIFactory<UDPSocketEventDispatcher>* | 23 BrowserContextKeyedAPIFactory<UDPSocketEventDispatcher>* |
| 23 UDPSocketEventDispatcher::GetFactoryInstance() { | 24 UDPSocketEventDispatcher::GetFactoryInstance() { |
| 24 return g_factory.Pointer(); | 25 return g_factory.Pointer(); |
| 25 } | 26 } |
| 26 | 27 |
| 27 // static | 28 // static |
| 28 UDPSocketEventDispatcher* UDPSocketEventDispatcher::Get( | 29 UDPSocketEventDispatcher* UDPSocketEventDispatcher::Get( |
| 29 content::BrowserContext* context) { | 30 content::BrowserContext* context) { |
| 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 31 | 32 |
| 32 return ProfileKeyedAPIFactory<UDPSocketEventDispatcher>::GetForProfile( | 33 return BrowserContextKeyedAPIFactory<UDPSocketEventDispatcher>::Get(context); |
| 33 context); | |
| 34 } | 34 } |
| 35 | 35 |
| 36 UDPSocketEventDispatcher::UDPSocketEventDispatcher( | 36 UDPSocketEventDispatcher::UDPSocketEventDispatcher( |
| 37 content::BrowserContext* context) | 37 content::BrowserContext* context) |
| 38 : thread_id_(Socket::kThreadId), browser_context_(context) { | 38 : thread_id_(Socket::kThreadId), browser_context_(context) { |
| 39 ApiResourceManager<ResumableUDPSocket>* manager = | 39 ApiResourceManager<ResumableUDPSocket>* manager = |
| 40 ApiResourceManager<ResumableUDPSocket>::Get(browser_context_); | 40 ApiResourceManager<ResumableUDPSocket>::Get(browser_context_); |
| 41 DCHECK(manager) << "There is no socket manager. " | 41 DCHECK(manager) << "There is no socket manager. " |
| 42 "If this assertion is failing during a test, then it is likely that " | 42 "If this assertion is failing during a test, then it is likely that " |
| 43 "TestExtensionSystem is failing to provide an instance of " | 43 "TestExtensionSystem is failing to provide an instance of " |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 reinterpret_cast<content::BrowserContext*>(browser_context_id); | 172 reinterpret_cast<content::BrowserContext*>(browser_context_id); |
| 173 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) | 173 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) |
| 174 return; | 174 return; |
| 175 EventRouter* router = ExtensionSystem::Get(context)->event_router(); | 175 EventRouter* router = ExtensionSystem::Get(context)->event_router(); |
| 176 if (router) | 176 if (router) |
| 177 router->DispatchEventToExtension(extension_id, event.Pass()); | 177 router->DispatchEventToExtension(extension_id, event.Pass()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace api | 180 } // namespace api |
| 181 } // namespace extensions | 181 } // namespace extensions |
| OLD | NEW |