Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: device/serial/serial_service_impl.cc

Issue 488363002: Implement the host side of serial connection I/O on data pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "device/serial/serial_service_impl.h" 5 #include "device/serial/serial_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "device/serial/serial_io_handler.h" 9 #include "device/serial/serial_io_handler.h"
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 void SerialServiceImpl::GetDevices( 50 void SerialServiceImpl::GetDevices(
51 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) { 51 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) {
52 callback.Run(GetDeviceEnumerator()->GetDevices()); 52 callback.Run(GetDeviceEnumerator()->GetDevices());
53 } 53 }
54 54
55 void SerialServiceImpl::Connect( 55 void SerialServiceImpl::Connect(
56 const mojo::String& path, 56 const mojo::String& path,
57 serial::ConnectionOptionsPtr options, 57 serial::ConnectionOptionsPtr options,
58 mojo::InterfaceRequest<serial::Connection> connection_request) { 58 mojo::InterfaceRequest<serial::Connection> connection_request,
59 mojo::InterfaceRequest<serial::DataSink> sink,
60 mojo::InterfaceRequest<serial::DataSource> source) {
59 if (!IsValidPath(path)) 61 if (!IsValidPath(path))
60 return; 62 return;
61 connection_factory_->CreateConnection( 63 connection_factory_->CreateConnection(path,
62 path, options.Pass(), connection_request.Pass()); 64 options.Pass(),
65 connection_request.Pass(),
66 sink.Pass(),
67 source.Pass());
63 } 68 }
64 69
65 SerialDeviceEnumerator* SerialServiceImpl::GetDeviceEnumerator() { 70 SerialDeviceEnumerator* SerialServiceImpl::GetDeviceEnumerator() {
66 if (!device_enumerator_) 71 if (!device_enumerator_)
67 device_enumerator_ = SerialDeviceEnumerator::Create(); 72 device_enumerator_ = SerialDeviceEnumerator::Create();
68 return device_enumerator_.get(); 73 return device_enumerator_.get();
69 } 74 }
70 75
71 bool SerialServiceImpl::IsValidPath(const mojo::String& path) { 76 bool SerialServiceImpl::IsValidPath(const mojo::String& path) {
72 mojo::Array<serial::DeviceInfoPtr> devices( 77 mojo::Array<serial::DeviceInfoPtr> devices(
73 GetDeviceEnumerator()->GetDevices()); 78 GetDeviceEnumerator()->GetDevices());
74 for (size_t i = 0; i < devices.size(); i++) { 79 for (size_t i = 0; i < devices.size(); i++) {
75 if (path == devices[i]->path) 80 if (path == devices[i]->path)
76 return true; 81 return true;
77 } 82 }
78 return false; 83 return false;
79 } 84 }
80 85
81 void SerialServiceImpl::OnConnected(
82 const mojo::Callback<void(serial::ConnectionInfoPtr)>& callback,
83 serial::ConnectionInfoPtr result) {
84 callback.Run(result.Pass());
85 }
86
87 } // namespace device 86 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698