| 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 "chrome/browser/extensions/api/bluetooth_socket/bluetooth_socket_event_
dispatcher.h" | 5 #include "extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatc
her.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | |
| 8 #include "chrome/browser/extensions/api/bluetooth_socket/bluetooth_api_socket.h" | |
| 9 #include "chrome/common/extensions/api/bluetooth_socket.h" | |
| 10 #include "device/bluetooth/bluetooth_device.h" | 7 #include "device/bluetooth/bluetooth_device.h" |
| 11 #include "device/bluetooth/bluetooth_socket.h" | 8 #include "device/bluetooth/bluetooth_socket.h" |
| 9 #include "extensions/browser/api/bluetooth_socket/bluetooth_api_socket.h" |
| 12 #include "extensions/browser/event_router.h" | 10 #include "extensions/browser/event_router.h" |
| 11 #include "extensions/common/api/bluetooth_socket.h" |
| 13 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
| 14 #include "net/base/net_errors.h" | |
| 15 | 13 |
| 16 namespace { | 14 namespace { |
| 17 | 15 |
| 18 namespace bluetooth_socket = extensions::api::bluetooth_socket; | 16 namespace bluetooth_socket = extensions::core_api::bluetooth_socket; |
| 19 using extensions::BluetoothApiSocket; | 17 using extensions::BluetoothApiSocket; |
| 20 | 18 |
| 21 int kDefaultBufferSize = 4096; | 19 int kDefaultBufferSize = 4096; |
| 22 | 20 |
| 23 bluetooth_socket::ReceiveError MapReceiveErrorReason( | 21 bluetooth_socket::ReceiveError MapReceiveErrorReason( |
| 24 BluetoothApiSocket::ErrorReason value) { | 22 BluetoothApiSocket::ErrorReason value) { |
| 25 switch (value) { | 23 switch (value) { |
| 26 case BluetoothApiSocket::kDisconnected: | 24 case BluetoothApiSocket::kDisconnected: |
| 27 return bluetooth_socket::RECEIVE_ERROR_DISCONNECTED; | 25 return bluetooth_socket::RECEIVE_ERROR_DISCONNECTED; |
| 28 case BluetoothApiSocket::kNotConnected: | 26 case BluetoothApiSocket::kNotConnected: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 48 // able to call Accept() on it. | 46 // able to call Accept() on it. |
| 49 // fallthrough | 47 // fallthrough |
| 50 default: | 48 default: |
| 51 return bluetooth_socket::ACCEPT_ERROR_SYSTEM_ERROR; | 49 return bluetooth_socket::ACCEPT_ERROR_SYSTEM_ERROR; |
| 52 } | 50 } |
| 53 } | 51 } |
| 54 | 52 |
| 55 } // namespace | 53 } // namespace |
| 56 | 54 |
| 57 namespace extensions { | 55 namespace extensions { |
| 58 namespace api { | 56 namespace core_api { |
| 59 | 57 |
| 60 using content::BrowserThread; | 58 using content::BrowserThread; |
| 61 | 59 |
| 62 static base::LazyInstance< | 60 static base::LazyInstance< |
| 63 BrowserContextKeyedAPIFactory<BluetoothSocketEventDispatcher> > g_factory = | 61 BrowserContextKeyedAPIFactory<BluetoothSocketEventDispatcher> > g_factory = |
| 64 LAZY_INSTANCE_INITIALIZER; | 62 LAZY_INSTANCE_INITIALIZER; |
| 65 | 63 |
| 66 // static | 64 // static |
| 67 BrowserContextKeyedAPIFactory<BluetoothSocketEventDispatcher>* | 65 BrowserContextKeyedAPIFactory<BluetoothSocketEventDispatcher>* |
| 68 BluetoothSocketEventDispatcher::GetFactoryInstance() { | 66 BluetoothSocketEventDispatcher::GetFactoryInstance() { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 content::BrowserContext* context = | 359 content::BrowserContext* context = |
| 362 reinterpret_cast<content::BrowserContext*>(browser_context_id); | 360 reinterpret_cast<content::BrowserContext*>(browser_context_id); |
| 363 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) | 361 if (!extensions::ExtensionsBrowserClient::Get()->IsValidContext(context)) |
| 364 return; | 362 return; |
| 365 | 363 |
| 366 EventRouter* router = EventRouter::Get(context); | 364 EventRouter* router = EventRouter::Get(context); |
| 367 if (router) | 365 if (router) |
| 368 router->DispatchEventToExtension(extension_id, event.Pass()); | 366 router->DispatchEventToExtension(extension_id, event.Pass()); |
| 369 } | 367 } |
| 370 | 368 |
| 371 } // namespace api | 369 } // namespace core_api |
| 372 } // namespace extensions | 370 } // namespace extensions |
| OLD | NEW |