| 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_tcp/tcp_socket_event_dispatcher.
h" | 5 #include "chrome/browser/extensions/api/sockets_tcp/tcp_socket_event_dispatcher.
h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/extensions/api/socket/tcp_socket.h" | 8 #include "chrome/browser/extensions/api/socket/tcp_socket.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "extensions/browser/event_router.h" | 12 #include "extensions/browser/event_router.h" |
| 13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 int kDefaultBufferSize = 4096; | 16 int kDefaultBufferSize = 4096; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace extensions { | 19 namespace extensions { |
| 20 namespace api { | 20 namespace api { |
| 21 | 21 |
| 22 using content::BrowserThread; | 22 using content::BrowserThread; |
| 23 | 23 |
| 24 static base::LazyInstance<ProfileKeyedAPIFactory<TCPSocketEventDispatcher> > | 24 static base::LazyInstance<ProfileKeyedAPIFactory<TCPSocketEventDispatcher> > |
| 25 g_factory = LAZY_INSTANCE_INITIALIZER; | 25 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 26 | 26 |
| 27 // static | 27 // static |
| 28 ProfileKeyedAPIFactory<TCPSocketEventDispatcher>* | 28 ProfileKeyedAPIFactory<TCPSocketEventDispatcher>* |
| 29 TCPSocketEventDispatcher::GetFactoryInstance() { | 29 TCPSocketEventDispatcher::GetFactoryInstance() { |
| 30 return &g_factory.Get(); | 30 return g_factory.Pointer(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 // static | 33 // static |
| 34 TCPSocketEventDispatcher* TCPSocketEventDispatcher::Get(Profile* profile) { | 34 TCPSocketEventDispatcher* TCPSocketEventDispatcher::Get(Profile* profile) { |
| 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 36 | 36 |
| 37 return ProfileKeyedAPIFactory<TCPSocketEventDispatcher>::GetForProfile( | 37 return ProfileKeyedAPIFactory<TCPSocketEventDispatcher>::GetForProfile( |
| 38 profile); | 38 profile); |
| 39 } | 39 } |
| 40 | 40 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) | 188 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) |
| 189 return; | 189 return; |
| 190 | 190 |
| 191 EventRouter* router = ExtensionSystem::Get(profile)->event_router(); | 191 EventRouter* router = ExtensionSystem::Get(profile)->event_router(); |
| 192 if (router) | 192 if (router) |
| 193 router->DispatchEventToExtension(extension_id, event.Pass()); | 193 router->DispatchEventToExtension(extension_id, event.Pass()); |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace api | 196 } // namespace api |
| 197 } // namespace extensions | 197 } // namespace extensions |
| OLD | NEW |