| 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" | |
| 9 #include "chrome/common/extensions/api/serial.h" | 8 #include "chrome/common/extensions/api/serial.h" |
| 9 #include "extensions/browser/api/api_resource_manager.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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 // BrowserContextKeyedAPI implementation. | 31 // BrowserContextKeyedAPI implementation. |
| 32 static BrowserContextKeyedAPIFactory<SerialEventDispatcher>* | 32 static BrowserContextKeyedAPIFactory<SerialEventDispatcher>* |
| 33 GetFactoryInstance(); | 33 GetFactoryInstance(); |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 typedef ApiResourceManager<SerialConnection>::ApiResourceData ConnectionData; | 36 typedef ApiResourceManager<SerialConnection>::ApiResourceData ConnectionData; |
| 37 friend class BrowserContextKeyedAPIFactory<SerialEventDispatcher>; | 37 friend class BrowserContextKeyedAPIFactory<SerialEventDispatcher>; |
| 38 | 38 |
| 39 // BrowserContextKeyedAPI implementation. | 39 // BrowserContextKeyedAPI implementation. |
| 40 static const char *service_name() { | 40 static const char* service_name() { return "SerialEventDispatcher"; } |
| 41 return "SerialEventDispatcher"; | |
| 42 } | |
| 43 static const bool kServiceHasOwnInstanceInIncognito = true; | 41 static const bool kServiceHasOwnInstanceInIncognito = true; |
| 44 static const bool kServiceIsNULLWhileTesting = true; | 42 static const bool kServiceIsNULLWhileTesting = true; |
| 45 | 43 |
| 46 struct ReceiveParams { | 44 struct ReceiveParams { |
| 47 ReceiveParams(); | 45 ReceiveParams(); |
| 48 ~ReceiveParams(); | 46 ~ReceiveParams(); |
| 49 | 47 |
| 50 content::BrowserThread::ID thread_id; | 48 content::BrowserThread::ID thread_id; |
| 51 void* profile_id; | 49 void* profile_id; |
| 52 std::string extension_id; | 50 std::string extension_id; |
| 53 scoped_refptr<ConnectionData> connections; | 51 scoped_refptr<ConnectionData> connections; |
| 54 int connection_id; | 52 int connection_id; |
| 55 }; | 53 }; |
| 56 | 54 |
| 57 static void StartReceive(const ReceiveParams& params); | 55 static void StartReceive(const ReceiveParams& params); |
| 58 | 56 |
| 59 static void ReceiveCallback(const ReceiveParams& params, | 57 static void ReceiveCallback(const ReceiveParams& params, |
| 60 const std::string& data, | 58 const std::string& data, |
| 61 serial::ReceiveError error); | 59 serial::ReceiveError error); |
| 62 | 60 |
| 63 static void PostEvent(const ReceiveParams& params, | 61 static void PostEvent(const ReceiveParams& params, |
| 64 scoped_ptr<extensions::Event> event); | 62 scoped_ptr<extensions::Event> event); |
| 65 | 63 |
| 66 static void DispatchEvent(void *profile_id, | 64 static void DispatchEvent(void* profile_id, |
| 67 const std::string& extension_id, | 65 const std::string& extension_id, |
| 68 scoped_ptr<extensions::Event> event); | 66 scoped_ptr<extensions::Event> event); |
| 69 | 67 |
| 70 content::BrowserThread::ID thread_id_; | 68 content::BrowserThread::ID thread_id_; |
| 71 Profile* const profile_; | 69 Profile* const profile_; |
| 72 scoped_refptr<ConnectionData> connections_; | 70 scoped_refptr<ConnectionData> connections_; |
| 73 }; | 71 }; |
| 74 | 72 |
| 75 } // namespace api | 73 } // namespace api |
| 76 | 74 |
| 77 } // namespace extensions | 75 } // namespace extensions |
| 78 | 76 |
| 79 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_EVENT_DISPATCHER_H_ | 77 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_EVENT_DISPATCHER_H_ |
| OLD | NEW |