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

Side by Side Diff: chrome/browser/extensions/api/sockets_tcp/tcp_socket_event_dispatcher.h

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 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKETS_TCP_TCP_SOCKET_EVENT_DISPATCHER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKETS_TCP_TCP_SOCKET_EVENT_DISPATCHER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKETS_TCP_TCP_SOCKET_EVENT_DISPATCHER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKETS_TCP_TCP_SOCKET_EVENT_DISPATCHER_H_
7 7
8 #include "chrome/browser/extensions/api/api_resource_manager.h" 8 #include "chrome/browser/extensions/api/api_resource_manager.h"
9 #include "chrome/browser/extensions/api/sockets_tcp/sockets_tcp_api.h" 9 #include "chrome/browser/extensions/api/sockets_tcp/sockets_tcp_api.h"
10 10
11 namespace extensions { 11 namespace extensions {
12 struct Event; 12 struct Event;
13 class ResumableTCPSocket; 13 class ResumableTCPSocket;
14 } 14 }
15 15
16 namespace extensions { 16 namespace extensions {
17 namespace api { 17 namespace api {
18 18
19 // Dispatch events related to "sockets.tcp" sockets from callback on native 19 // Dispatch events related to "sockets.tcp" sockets from callback on native
20 // socket instances. There is one instance per profile. 20 // socket instances. There is one instance per profile.
21 class TCPSocketEventDispatcher 21 class TCPSocketEventDispatcher
22 : public ProfileKeyedAPI, 22 : public ProfileKeyedAPI,
23 public base::SupportsWeakPtr<TCPSocketEventDispatcher> { 23 public base::SupportsWeakPtr<TCPSocketEventDispatcher> {
24 public: 24 public:
25 explicit TCPSocketEventDispatcher(Profile* profile); 25 explicit TCPSocketEventDispatcher(content::BrowserContext* context);
26 virtual ~TCPSocketEventDispatcher(); 26 virtual ~TCPSocketEventDispatcher();
27 27
28 // Socket is active, start receving from it. 28 // Socket is active, start receving from it.
29 void OnSocketConnect(const std::string& extension_id, int socket_id); 29 void OnSocketConnect(const std::string& extension_id, int socket_id);
30 30
31 // Socket is active again, start receiving data from it. 31 // Socket is active again, start receiving data from it.
32 void OnSocketResume(const std::string& extension_id, int socket_id); 32 void OnSocketResume(const std::string& extension_id, int socket_id);
33 33
34 // ProfileKeyedAPI implementation. 34 // ProfileKeyedAPI implementation.
35 static ProfileKeyedAPIFactory<TCPSocketEventDispatcher>* GetFactoryInstance(); 35 static ProfileKeyedAPIFactory<TCPSocketEventDispatcher>* GetFactoryInstance();
36 36
37 // Convenience method to get the SocketEventDispatcher for a profile. 37 // Convenience method to get the SocketEventDispatcher for a profile.
38 static TCPSocketEventDispatcher* Get(Profile* profile); 38 static TCPSocketEventDispatcher* Get(content::BrowserContext* context);
39 39
40 private: 40 private:
41 typedef ApiResourceManager<ResumableTCPSocket>::ApiResourceData SocketData; 41 typedef ApiResourceManager<ResumableTCPSocket>::ApiResourceData SocketData;
42 friend class ProfileKeyedAPIFactory<TCPSocketEventDispatcher>; 42 friend class ProfileKeyedAPIFactory<TCPSocketEventDispatcher>;
43 // ProfileKeyedAPI implementation. 43 // ProfileKeyedAPI implementation.
44 static const char* service_name() { 44 static const char* service_name() {
45 return "TCPSocketEventDispatcher"; 45 return "TCPSocketEventDispatcher";
46 } 46 }
47 static const bool kServiceHasOwnInstanceInIncognito = true; 47 static const bool kServiceHasOwnInstanceInIncognito = true;
48 static const bool kServiceIsNULLWhileTesting = true; 48 static const bool kServiceIsNULLWhileTesting = true;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // Usually IO thread (except for unit testing). 82 // Usually IO thread (except for unit testing).
83 content::BrowserThread::ID thread_id_; 83 content::BrowserThread::ID thread_id_;
84 Profile* const profile_; 84 Profile* const profile_;
85 scoped_refptr<SocketData> sockets_; 85 scoped_refptr<SocketData> sockets_;
86 }; 86 };
87 87
88 } // namespace api 88 } // namespace api
89 } // namespace extensions 89 } // namespace extensions
90 90
91 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKETS_TCP_TCP_SOCKET_EVENT_DISPATCHER _H_ 91 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKETS_TCP_TCP_SOCKET_EVENT_DISPATCHER _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698