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 #ifndef CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_EVENT_DISPATCHER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_EVENT_DISPATCHER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_EVENT_DISPATCHER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_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/common/extensions/api/serial.h" | 9 #include "chrome/common/extensions/api/serial.h" |
10 | 10 |
11 class Profile; | 11 class Profile; |
12 | 12 |
13 namespace extensions { | 13 namespace extensions { |
14 | 14 |
15 struct Event; | 15 struct Event; |
16 class SerialConnection; | 16 class SerialConnection; |
17 | 17 |
18 namespace api { | 18 namespace api { |
19 | 19 |
20 // Per-profile dispatcher for events on serial connections. | 20 // Per-profile dispatcher for events on serial connections. |
21 class SerialEventDispatcher : public ProfileKeyedAPI { | 21 class SerialEventDispatcher : public BrowserContextKeyedAPI { |
22 public: | 22 public: |
23 explicit SerialEventDispatcher(content::BrowserContext* context); | 23 explicit SerialEventDispatcher(content::BrowserContext* context); |
24 virtual ~SerialEventDispatcher(); | 24 virtual ~SerialEventDispatcher(); |
25 | 25 |
26 // Start receiving data and firing events for a connection. | 26 // Start receiving data and firing events for a connection. |
27 void PollConnection(const std::string& extension_id, int connection_id); | 27 void PollConnection(const std::string& extension_id, int connection_id); |
28 | 28 |
29 static SerialEventDispatcher* Get(content::BrowserContext* context); | 29 static SerialEventDispatcher* Get(content::BrowserContext* context); |
30 | 30 |
31 // ProfileKeyedAPI implementation. | 31 // BrowserContextKeyedAPI implementation. |
32 static ProfileKeyedAPIFactory<SerialEventDispatcher>* GetFactoryInstance(); | 32 static BrowserContextKeyedAPIFactory<SerialEventDispatcher>* |
| 33 GetFactoryInstance(); |
33 | 34 |
34 private: | 35 private: |
35 typedef ApiResourceManager<SerialConnection>::ApiResourceData ConnectionData; | 36 typedef ApiResourceManager<SerialConnection>::ApiResourceData ConnectionData; |
36 friend class ProfileKeyedAPIFactory<SerialEventDispatcher>; | 37 friend class BrowserContextKeyedAPIFactory<SerialEventDispatcher>; |
37 | 38 |
38 // ProfileKeyedAPI implementation. | 39 // BrowserContextKeyedAPI implementation. |
39 static const char *service_name() { | 40 static const char *service_name() { |
40 return "SerialEventDispatcher"; | 41 return "SerialEventDispatcher"; |
41 } | 42 } |
42 static const bool kServiceHasOwnInstanceInIncognito = true; | 43 static const bool kServiceHasOwnInstanceInIncognito = true; |
43 static const bool kServiceIsNULLWhileTesting = true; | 44 static const bool kServiceIsNULLWhileTesting = true; |
44 | 45 |
45 struct ReceiveParams { | 46 struct ReceiveParams { |
46 ReceiveParams(); | 47 ReceiveParams(); |
47 ~ReceiveParams(); | 48 ~ReceiveParams(); |
48 | 49 |
(...skipping 20 matching lines...) Expand all Loading... |
69 content::BrowserThread::ID thread_id_; | 70 content::BrowserThread::ID thread_id_; |
70 Profile* const profile_; | 71 Profile* const profile_; |
71 scoped_refptr<ConnectionData> connections_; | 72 scoped_refptr<ConnectionData> connections_; |
72 }; | 73 }; |
73 | 74 |
74 } // namespace api | 75 } // namespace api |
75 | 76 |
76 } // namespace extensions | 77 } // namespace extensions |
77 | 78 |
78 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_EVENT_DISPATCHER_H_ | 79 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_EVENT_DISPATCHER_H_ |
OLD | NEW |