Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: chrome/browser/extensions/api/sockets_udp/udp_socket_event_dispatcher.cc

Issue 174513003: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 3). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/extensions/api/socket/udp_socket.h" 8 #include "chrome/browser/extensions/api/socket/udp_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"
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 "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 namespace api { 16 namespace api {
17 17
18 using content::BrowserThread; 18 using content::BrowserThread;
19 19
20 static base::LazyInstance<ProfileKeyedAPIFactory<UDPSocketEventDispatcher> > 20 static base::LazyInstance<ProfileKeyedAPIFactory<UDPSocketEventDispatcher> >
21 g_factory = LAZY_INSTANCE_INITIALIZER; 21 g_factory = LAZY_INSTANCE_INITIALIZER;
22 22
23 // static 23 // static
24 ProfileKeyedAPIFactory<UDPSocketEventDispatcher>* 24 ProfileKeyedAPIFactory<UDPSocketEventDispatcher>*
25 UDPSocketEventDispatcher::GetFactoryInstance() { 25 UDPSocketEventDispatcher::GetFactoryInstance() {
26 return g_factory.Pointer(); 26 return g_factory.Pointer();
27 } 27 }
28 28
29 // static 29 // static
30 UDPSocketEventDispatcher* UDPSocketEventDispatcher::Get(Profile* profile) { 30 UDPSocketEventDispatcher* UDPSocketEventDispatcher::Get(
31 content::BrowserContext* context) {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
32 33
33 return ProfileKeyedAPIFactory<UDPSocketEventDispatcher>::GetForProfile( 34 return ProfileKeyedAPIFactory<UDPSocketEventDispatcher>::GetForProfile(
34 profile); 35 context);
35 } 36 }
36 37
37 UDPSocketEventDispatcher::UDPSocketEventDispatcher(Profile* profile) 38 UDPSocketEventDispatcher::UDPSocketEventDispatcher(
39 content::BrowserContext* context)
38 : thread_id_(Socket::kThreadId), 40 : thread_id_(Socket::kThreadId),
39 profile_(profile) { 41 profile_(Profile::FromBrowserContext(context)) {
40 ApiResourceManager<ResumableUDPSocket>* manager = 42 ApiResourceManager<ResumableUDPSocket>* manager =
41 ApiResourceManager<ResumableUDPSocket>::Get(profile); 43 ApiResourceManager<ResumableUDPSocket>::Get(profile_);
42 DCHECK(manager) << "There is no socket manager. " 44 DCHECK(manager) << "There is no socket manager. "
43 "If this assertion is failing during a test, then it is likely that " 45 "If this assertion is failing during a test, then it is likely that "
44 "TestExtensionSystem is failing to provide an instance of " 46 "TestExtensionSystem is failing to provide an instance of "
45 "ApiResourceManager<ResumableUDPSocket>."; 47 "ApiResourceManager<ResumableUDPSocket>.";
46 sockets_ = manager->data_; 48 sockets_ = manager->data_;
47 } 49 }
48 50
49 UDPSocketEventDispatcher::~UDPSocketEventDispatcher() {} 51 UDPSocketEventDispatcher::~UDPSocketEventDispatcher() {}
50 52
51 UDPSocketEventDispatcher::ReceiveParams::ReceiveParams() {} 53 UDPSocketEventDispatcher::ReceiveParams::ReceiveParams() {}
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) 175 if (!g_browser_process->profile_manager()->IsValidProfile(profile))
174 return; 176 return;
175 177
176 EventRouter* router = ExtensionSystem::Get(profile)->event_router(); 178 EventRouter* router = ExtensionSystem::Get(profile)->event_router();
177 if (router) 179 if (router)
178 router->DispatchEventToExtension(extension_id, event.Pass()); 180 router->DispatchEventToExtension(extension_id, event.Pass());
179 } 181 }
180 182
181 } // namespace api 183 } // namespace api
182 } // namespace extensions 184 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698