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/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 13 matching lines...) Expand all Loading... |
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.Pointer(); | 30 return g_factory.Pointer(); |
31 } | 31 } |
32 | 32 |
33 // static | 33 // static |
34 TCPSocketEventDispatcher* TCPSocketEventDispatcher::Get(Profile* profile) { | 34 TCPSocketEventDispatcher* TCPSocketEventDispatcher::Get( |
| 35 content::BrowserContext* context) { |
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
36 | 37 |
37 return ProfileKeyedAPIFactory<TCPSocketEventDispatcher>::GetForProfile( | 38 return ProfileKeyedAPIFactory<TCPSocketEventDispatcher>::GetForProfile( |
38 profile); | 39 context); |
39 } | 40 } |
40 | 41 |
41 TCPSocketEventDispatcher::TCPSocketEventDispatcher(Profile* profile) | 42 TCPSocketEventDispatcher::TCPSocketEventDispatcher( |
| 43 content::BrowserContext* context) |
42 : thread_id_(Socket::kThreadId), | 44 : thread_id_(Socket::kThreadId), |
43 profile_(profile) { | 45 profile_(Profile::FromBrowserContext(context)) { |
44 ApiResourceManager<ResumableTCPSocket>* manager = | 46 ApiResourceManager<ResumableTCPSocket>* manager = |
45 ApiResourceManager<ResumableTCPSocket>::Get(profile); | 47 ApiResourceManager<ResumableTCPSocket>::Get(profile_); |
46 DCHECK(manager) << "There is no socket manager. " | 48 DCHECK(manager) << "There is no socket manager. " |
47 "If this assertion is failing during a test, then it is likely that " | 49 "If this assertion is failing during a test, then it is likely that " |
48 "TestExtensionSystem is failing to provide an instance of " | 50 "TestExtensionSystem is failing to provide an instance of " |
49 "ApiResourceManager<ResumableTCPSocket>."; | 51 "ApiResourceManager<ResumableTCPSocket>."; |
50 sockets_ = manager->data_; | 52 sockets_ = manager->data_; |
51 } | 53 } |
52 | 54 |
53 TCPSocketEventDispatcher::~TCPSocketEventDispatcher() {} | 55 TCPSocketEventDispatcher::~TCPSocketEventDispatcher() {} |
54 | 56 |
55 TCPSocketEventDispatcher::ReadParams::ReadParams() {} | 57 TCPSocketEventDispatcher::ReadParams::ReadParams() {} |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) | 190 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) |
189 return; | 191 return; |
190 | 192 |
191 EventRouter* router = ExtensionSystem::Get(profile)->event_router(); | 193 EventRouter* router = ExtensionSystem::Get(profile)->event_router(); |
192 if (router) | 194 if (router) |
193 router->DispatchEventToExtension(extension_id, event.Pass()); | 195 router->DispatchEventToExtension(extension_id, event.Pass()); |
194 } | 196 } |
195 | 197 |
196 } // namespace api | 198 } // namespace api |
197 } // namespace extensions | 199 } // namespace extensions |
OLD | NEW |