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