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 namespace extensions { | 11 namespace extensions { |
12 | 12 |
13 struct Event; | 13 struct Event; |
14 class SerialConnection; | 14 class SerialConnection; |
15 | 15 |
16 namespace api { | 16 namespace api { |
17 | 17 |
18 // Per-profile dispatcher for events on serial connections. | 18 // Per-profile dispatcher for events on serial connections. |
19 class SerialEventDispatcher : public ProfileKeyedAPI { | 19 class SerialEventDispatcher : public ProfileKeyedAPI { |
20 public: | 20 public: |
21 explicit SerialEventDispatcher(Profile* profile); | 21 explicit SerialEventDispatcher(content::BrowserContext* context); |
22 virtual ~SerialEventDispatcher(); | 22 virtual ~SerialEventDispatcher(); |
23 | 23 |
24 // Start receiving data and firing events for a connection. | 24 // Start receiving data and firing events for a connection. |
25 void PollConnection(const std::string& extension_id, int connection_id); | 25 void PollConnection(const std::string& extension_id, int connection_id); |
26 | 26 |
27 static SerialEventDispatcher* Get(Profile* profile); | 27 static SerialEventDispatcher* Get(content::BrowserContext* context); |
28 | 28 |
29 // ProfileKeyedAPI implementation. | 29 // ProfileKeyedAPI implementation. |
30 static ProfileKeyedAPIFactory<SerialEventDispatcher>* GetFactoryInstance(); | 30 static ProfileKeyedAPIFactory<SerialEventDispatcher>* GetFactoryInstance(); |
31 | 31 |
32 private: | 32 private: |
33 typedef ApiResourceManager<SerialConnection>::ApiResourceData ConnectionData; | 33 typedef ApiResourceManager<SerialConnection>::ApiResourceData ConnectionData; |
34 friend class ProfileKeyedAPIFactory<SerialEventDispatcher>; | 34 friend class ProfileKeyedAPIFactory<SerialEventDispatcher>; |
35 | 35 |
36 // ProfileKeyedAPI implementation. | 36 // ProfileKeyedAPI implementation. |
37 static const char *service_name() { | 37 static const char *service_name() { |
(...skipping 29 matching lines...) Expand all Loading... |
67 content::BrowserThread::ID thread_id_; | 67 content::BrowserThread::ID thread_id_; |
68 Profile* const profile_; | 68 Profile* const profile_; |
69 scoped_refptr<ConnectionData> connections_; | 69 scoped_refptr<ConnectionData> connections_; |
70 }; | 70 }; |
71 | 71 |
72 } // namespace api | 72 } // namespace api |
73 | 73 |
74 } // namespace extensions | 74 } // namespace extensions |
75 | 75 |
76 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_EVENT_DISPATCHER_H_ | 76 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_EVENT_DISPATCHER_H_ |
OLD | NEW |