| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "chrome/browser/extensions/api/api_function.h" | |
| 12 #include "chrome/browser/extensions/api/api_resource_manager.h" | 11 #include "chrome/browser/extensions/api/api_resource_manager.h" |
| 13 #include "chrome/common/extensions/api/serial.h" | 12 #include "chrome/common/extensions/api/serial.h" |
| 13 #include "extensions/browser/api/async_api_function.h" |
| 14 | 14 |
| 15 namespace extensions { | 15 namespace extensions { |
| 16 | 16 |
| 17 class SerialConnection; | 17 class SerialConnection; |
| 18 | 18 |
| 19 namespace api { | 19 namespace api { |
| 20 | 20 |
| 21 class SerialEventDispatcher; | 21 class SerialEventDispatcher; |
| 22 | 22 |
| 23 class SerialAsyncApiFunction : public AsyncApiFunction { | 23 class SerialAsyncApiFunction : public AsyncApiFunction { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 virtual SerialConnection* CreateSerialConnection( | 67 virtual SerialConnection* CreateSerialConnection( |
| 68 const std::string& port, | 68 const std::string& port, |
| 69 const std::string& extension_id) const; | 69 const std::string& extension_id) const; |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 void OnConnected(bool success); | 72 void OnConnected(bool success); |
| 73 void FinishConnect(); | 73 void FinishConnect(); |
| 74 | 74 |
| 75 scoped_ptr<serial::Connect::Params> params_; | 75 scoped_ptr<serial::Connect::Params> params_; |
| 76 | 76 |
| 77 // SerialEventDispatcher is owned by a Profile. | 77 // SerialEventDispatcher is owned by a BrowserContext. |
| 78 SerialEventDispatcher* serial_event_dispatcher_; | 78 SerialEventDispatcher* serial_event_dispatcher_; |
| 79 | 79 |
| 80 // This connection is created within SerialConnectFunction. | 80 // This connection is created within SerialConnectFunction. |
| 81 // From there it is either destroyed in OnConnected (upon failure) | 81 // From there it is either destroyed in OnConnected (upon failure) |
| 82 // or its ownership is transferred to the profile's. | 82 // or its ownership is transferred to the browser context's. |
| 83 // ApiResourceManager<SerialConnection>. | 83 // ApiResourceManager<SerialConnection>. |
| 84 SerialConnection* connection_; | 84 SerialConnection* connection_; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 class SerialUpdateFunction : public SerialAsyncApiFunction { | 87 class SerialUpdateFunction : public SerialAsyncApiFunction { |
| 88 public: | 88 public: |
| 89 DECLARE_EXTENSION_FUNCTION("serial.update", SERIAL_UPDATE); | 89 DECLARE_EXTENSION_FUNCTION("serial.update", SERIAL_UPDATE); |
| 90 | 90 |
| 91 SerialUpdateFunction(); | 91 SerialUpdateFunction(); |
| 92 | 92 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 237 |
| 238 private: | 238 private: |
| 239 scoped_ptr<serial::SetControlSignals::Params> params_; | 239 scoped_ptr<serial::SetControlSignals::Params> params_; |
| 240 }; | 240 }; |
| 241 | 241 |
| 242 } // namespace api | 242 } // namespace api |
| 243 | 243 |
| 244 } // namespace extensions | 244 } // namespace extensions |
| 245 | 245 |
| 246 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ | 246 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ |
| OLD | NEW |