OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "extensions/browser/api/serial/serial_event_dispatcher.h" | 5 #include "extensions/browser/api/serial/serial_event_dispatcher.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "extensions/browser/api/serial/serial_connection.h" | 8 #include "extensions/browser/api/serial/serial_connection.h" |
9 #include "extensions/browser/event_router.h" | 9 #include "extensions/browser/event_router.h" |
10 #include "extensions/browser/extensions_browser_client.h" | 10 #include "extensions/browser/extensions_browser_client.h" |
11 | 11 |
12 namespace extensions { | 12 namespace extensions { |
13 | 13 |
14 namespace core_api { | 14 namespace api { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 bool ShouldPauseOnReceiveError(serial::ReceiveError error) { | 18 bool ShouldPauseOnReceiveError(serial::ReceiveError error) { |
19 return error == serial::RECEIVE_ERROR_DEVICE_LOST || | 19 return error == serial::RECEIVE_ERROR_DEVICE_LOST || |
20 error == serial::RECEIVE_ERROR_SYSTEM_ERROR || | 20 error == serial::RECEIVE_ERROR_SYSTEM_ERROR || |
21 error == serial::RECEIVE_ERROR_DISCONNECTED || | 21 error == serial::RECEIVE_ERROR_DISCONNECTED || |
22 error == serial::RECEIVE_ERROR_BREAK || | 22 error == serial::RECEIVE_ERROR_BREAK || |
23 error == serial::RECEIVE_ERROR_FRAME_ERROR || | 23 error == serial::RECEIVE_ERROR_FRAME_ERROR || |
24 error == serial::RECEIVE_ERROR_OVERRUN || | 24 error == serial::RECEIVE_ERROR_OVERRUN || |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 content::BrowserContext* context = | 154 content::BrowserContext* context = |
155 reinterpret_cast<content::BrowserContext*>(browser_context_id); | 155 reinterpret_cast<content::BrowserContext*>(browser_context_id); |
156 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) | 156 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) |
157 return; | 157 return; |
158 | 158 |
159 EventRouter* router = EventRouter::Get(context); | 159 EventRouter* router = EventRouter::Get(context); |
160 if (router) | 160 if (router) |
161 router->DispatchEventToExtension(extension_id, event.Pass()); | 161 router->DispatchEventToExtension(extension_id, event.Pass()); |
162 } | 162 } |
163 | 163 |
164 } // namespace core_api | 164 } // namespace api |
165 | 165 |
166 } // namespace extensions | 166 } // namespace extensions |
OLD | NEW |