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_api.h" | 5 #include "extensions/browser/api/bluetooth_socket/bluetooth_socket_api.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 namespace { | 30 namespace { |
31 | 31 |
32 const char kDeviceNotFoundError[] = "Device not found"; | 32 const char kDeviceNotFoundError[] = "Device not found"; |
33 const char kInvalidPsmError[] = "Invalid PSM"; | 33 const char kInvalidPsmError[] = "Invalid PSM"; |
34 const char kInvalidUuidError[] = "Invalid UUID"; | 34 const char kInvalidUuidError[] = "Invalid UUID"; |
35 const char kPermissionDeniedError[] = "Permission denied"; | 35 const char kPermissionDeniedError[] = "Permission denied"; |
36 const char kSocketNotFoundError[] = "Socket not found"; | 36 const char kSocketNotFoundError[] = "Socket not found"; |
37 | 37 |
38 linked_ptr<SocketInfo> CreateSocketInfo(int socket_id, | 38 linked_ptr<SocketInfo> CreateSocketInfo(int socket_id, |
39 BluetoothApiSocket* socket) { | 39 BluetoothApiSocket* socket) { |
40 DCHECK(BrowserThread::CurrentlyOn(BluetoothApiSocket::kThreadId)); | 40 DCHECK_CURRENTLY_ON(BluetoothApiSocket::kThreadId); |
41 linked_ptr<SocketInfo> socket_info(new SocketInfo()); | 41 linked_ptr<SocketInfo> socket_info(new SocketInfo()); |
42 // This represents what we know about the socket, and does not call through | 42 // This represents what we know about the socket, and does not call through |
43 // to the system. | 43 // to the system. |
44 socket_info->socket_id = socket_id; | 44 socket_info->socket_id = socket_id; |
45 if (socket->name()) { | 45 if (socket->name()) { |
46 socket_info->name.reset(new std::string(*socket->name())); | 46 socket_info->name.reset(new std::string(*socket->name())); |
47 } | 47 } |
48 socket_info->persistent = socket->persistent(); | 48 socket_info->persistent = socket->persistent(); |
49 if (socket->buffer_size() > 0) { | 49 if (socket->buffer_size() > 0) { |
50 socket_info->buffer_size.reset(new int(socket->buffer_size())); | 50 socket_info->buffer_size.reset(new int(socket->buffer_size())); |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 if (socket) { | 669 if (socket) { |
670 socket_infos.push_back(CreateSocketInfo(socket_id, socket)); | 670 socket_infos.push_back(CreateSocketInfo(socket_id, socket)); |
671 } | 671 } |
672 } | 672 } |
673 } | 673 } |
674 results_ = bluetooth_socket::GetSockets::Results::Create(socket_infos); | 674 results_ = bluetooth_socket::GetSockets::Results::Create(socket_infos); |
675 } | 675 } |
676 | 676 |
677 } // namespace core_api | 677 } // namespace core_api |
678 } // namespace extensions | 678 } // namespace extensions |
OLD | NEW |