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

Side by Side Diff: chrome/browser/extensions/api/sockets_tcp/tcp_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_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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698