OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/serial/serial_api.h" | 5 #include "chrome/browser/extensions/api/serial/serial_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/extensions/api/serial/serial_connection.h" | 10 #include "chrome/browser/extensions/api/serial/serial_connection.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 bool SerialGetDevicesFunction::Prepare() { | 80 bool SerialGetDevicesFunction::Prepare() { |
81 set_work_thread_id(BrowserThread::FILE); | 81 set_work_thread_id(BrowserThread::FILE); |
82 return true; | 82 return true; |
83 } | 83 } |
84 | 84 |
85 void SerialGetDevicesFunction::Work() { | 85 void SerialGetDevicesFunction::Work() { |
86 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 86 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
87 | 87 |
88 scoped_ptr<device::SerialDeviceEnumerator> enumerator = | 88 scoped_ptr<device::SerialDeviceEnumerator> enumerator = |
89 device::SerialDeviceEnumerator::Create(); | 89 device::SerialDeviceEnumerator::Create(); |
90 mojo::Array<device::SerialDeviceInfoPtr> devices = enumerator->GetDevices(); | 90 mojo::Array<device::serial::DeviceInfoPtr> devices = enumerator->GetDevices(); |
91 results_ = serial::GetDevices::Results::Create( | 91 results_ = serial::GetDevices::Results::Create( |
92 devices.To<std::vector<linked_ptr<serial::DeviceInfo> > >()); | 92 devices.To<std::vector<linked_ptr<serial::DeviceInfo> > >()); |
93 } | 93 } |
94 | 94 |
95 SerialConnectFunction::SerialConnectFunction() {} | 95 SerialConnectFunction::SerialConnectFunction() {} |
96 | 96 |
97 SerialConnectFunction::~SerialConnectFunction() {} | 97 SerialConnectFunction::~SerialConnectFunction() {} |
98 | 98 |
99 bool SerialConnectFunction::Prepare() { | 99 bool SerialConnectFunction::Prepare() { |
100 params_ = serial::Connect::Params::Create(*args_); | 100 params_ = serial::Connect::Params::Create(*args_); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 404 } |
405 | 405 |
406 } // namespace api | 406 } // namespace api |
407 | 407 |
408 } // namespace extensions | 408 } // namespace extensions |
409 | 409 |
410 namespace mojo { | 410 namespace mojo { |
411 | 411 |
412 // static | 412 // static |
413 linked_ptr<extensions::api::serial::DeviceInfo> | 413 linked_ptr<extensions::api::serial::DeviceInfo> |
414 TypeConverter<device::SerialDeviceInfoPtr, | 414 TypeConverter<device::serial::DeviceInfoPtr, |
415 linked_ptr<extensions::api::serial::DeviceInfo> >:: | 415 linked_ptr<extensions::api::serial::DeviceInfo> >:: |
416 ConvertTo(const device::SerialDeviceInfoPtr& device) { | 416 ConvertTo(const device::serial::DeviceInfoPtr& device) { |
417 linked_ptr<extensions::api::serial::DeviceInfo> info( | 417 linked_ptr<extensions::api::serial::DeviceInfo> info( |
418 new extensions::api::serial::DeviceInfo); | 418 new extensions::api::serial::DeviceInfo); |
419 info->path = device->path; | 419 info->path = device->path; |
420 if (device->has_vendor_id) | 420 if (device->has_vendor_id) |
421 info->vendor_id.reset(new int(static_cast<int>(device->vendor_id))); | 421 info->vendor_id.reset(new int(static_cast<int>(device->vendor_id))); |
422 if (device->has_product_id) | 422 if (device->has_product_id) |
423 info->product_id.reset(new int(static_cast<int>(device->product_id))); | 423 info->product_id.reset(new int(static_cast<int>(device->product_id))); |
424 if (device->display_name) | 424 if (device->display_name) |
425 info->display_name.reset(new std::string(device->display_name)); | 425 info->display_name.reset(new std::string(device->display_name)); |
426 return info; | 426 return info; |
427 } | 427 } |
428 | 428 |
429 } // namespace mojo | 429 } // namespace mojo |
OLD | NEW |