| 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_api.h" | 5 #include "extensions/browser/api/serial/serial_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 const serial::ParityBit kDefaultParityBit = serial::PARITY_BIT_NO; | 36 const serial::ParityBit kDefaultParityBit = serial::PARITY_BIT_NO; |
| 37 const serial::StopBits kDefaultStopBits = serial::STOP_BITS_ONE; | 37 const serial::StopBits kDefaultStopBits = serial::STOP_BITS_ONE; |
| 38 const int kDefaultReceiveTimeout = 0; | 38 const int kDefaultReceiveTimeout = 0; |
| 39 const int kDefaultSendTimeout = 0; | 39 const int kDefaultSendTimeout = 0; |
| 40 | 40 |
| 41 const char kErrorConnectFailed[] = "Failed to connect to the port."; | 41 const char kErrorConnectFailed[] = "Failed to connect to the port."; |
| 42 const char kErrorSerialConnectionNotFound[] = "Serial connection not found."; | 42 const char kErrorSerialConnectionNotFound[] = "Serial connection not found."; |
| 43 const char kErrorGetControlSignalsFailed[] = "Failed to get control signals."; | 43 const char kErrorGetControlSignalsFailed[] = "Failed to get control signals."; |
| 44 | 44 |
| 45 template <class T> | 45 template <class T> |
| 46 void SetDefaultScopedPtrValue(scoped_ptr<T>& ptr, const T& value) { | 46 void SetDefaultScopedPtrValue(std::unique_ptr<T>& ptr, const T& value) { |
| 47 if (!ptr.get()) | 47 if (!ptr.get()) |
| 48 ptr.reset(new T(value)); | 48 ptr.reset(new T(value)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 SerialAsyncApiFunction::SerialAsyncApiFunction() : manager_(NULL) { | 53 SerialAsyncApiFunction::SerialAsyncApiFunction() : manager_(NULL) { |
| 54 } | 54 } |
| 55 | 55 |
| 56 SerialAsyncApiFunction::~SerialAsyncApiFunction() { | 56 SerialAsyncApiFunction::~SerialAsyncApiFunction() { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool SerialGetDevicesFunction::Prepare() { | 81 bool SerialGetDevicesFunction::Prepare() { |
| 82 set_work_thread_id(BrowserThread::FILE); | 82 set_work_thread_id(BrowserThread::FILE); |
| 83 return true; | 83 return true; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void SerialGetDevicesFunction::Work() { | 86 void SerialGetDevicesFunction::Work() { |
| 87 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 87 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 88 | 88 |
| 89 scoped_ptr<device::SerialDeviceEnumerator> enumerator = | 89 std::unique_ptr<device::SerialDeviceEnumerator> enumerator = |
| 90 device::SerialDeviceEnumerator::Create(); | 90 device::SerialDeviceEnumerator::Create(); |
| 91 mojo::Array<device::serial::DeviceInfoPtr> devices = enumerator->GetDevices(); | 91 mojo::Array<device::serial::DeviceInfoPtr> devices = enumerator->GetDevices(); |
| 92 results_ = serial::GetDevices::Results::Create( | 92 results_ = serial::GetDevices::Results::Create( |
| 93 devices.To<std::vector<serial::DeviceInfo>>()); | 93 devices.To<std::vector<serial::DeviceInfo>>()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 SerialConnectFunction::SerialConnectFunction() { | 96 SerialConnectFunction::SerialConnectFunction() { |
| 97 } | 97 } |
| 98 | 98 |
| 99 SerialConnectFunction::~SerialConnectFunction() { | 99 SerialConnectFunction::~SerialConnectFunction() { |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 if (device->has_vendor_id) | 486 if (device->has_vendor_id) |
| 487 info.vendor_id.reset(new int(static_cast<int>(device->vendor_id))); | 487 info.vendor_id.reset(new int(static_cast<int>(device->vendor_id))); |
| 488 if (device->has_product_id) | 488 if (device->has_product_id) |
| 489 info.product_id.reset(new int(static_cast<int>(device->product_id))); | 489 info.product_id.reset(new int(static_cast<int>(device->product_id))); |
| 490 if (device->display_name) | 490 if (device->display_name) |
| 491 info.display_name.reset(new std::string(device->display_name)); | 491 info.display_name.reset(new std::string(device->display_name)); |
| 492 return info; | 492 return info; |
| 493 } | 493 } |
| 494 | 494 |
| 495 } // namespace mojo | 495 } // namespace mojo |
| OLD | NEW |