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

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

Issue 873293006: Revert of Remove Client= from device/serial/data_stream.mojom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « device/serial/serial_service_impl.h ('k') | device/serial/serial_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 void SerialServiceImpl::GetDevices( 54 void SerialServiceImpl::GetDevices(
55 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) { 55 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) {
56 callback.Run(GetDeviceEnumerator()->GetDevices()); 56 callback.Run(GetDeviceEnumerator()->GetDevices());
57 } 57 }
58 58
59 void SerialServiceImpl::Connect( 59 void SerialServiceImpl::Connect(
60 const mojo::String& path, 60 const mojo::String& path,
61 serial::ConnectionOptionsPtr options, 61 serial::ConnectionOptionsPtr options,
62 mojo::InterfaceRequest<serial::Connection> connection_request, 62 mojo::InterfaceRequest<serial::Connection> connection_request,
63 mojo::InterfaceRequest<serial::DataSink> sink, 63 mojo::InterfaceRequest<serial::DataSink> sink,
64 mojo::InterfacePtr<serial::DataSinkClient> sink_client, 64 mojo::InterfaceRequest<serial::DataSource> source) {
65 mojo::InterfaceRequest<serial::DataSource> source,
66 mojo::InterfacePtr<serial::DataSourceClient> source_client) {
67 if (!IsValidPath(path)) 65 if (!IsValidPath(path))
68 return; 66 return;
69 connection_factory_->CreateConnection( 67 connection_factory_->CreateConnection(path,
70 path, options.Pass(), connection_request.Pass(), sink.Pass(), 68 options.Pass(),
71 sink_client.Pass(), source.Pass(), source_client.Pass()); 69 connection_request.Pass(),
70 sink.Pass(),
71 source.Pass());
72 } 72 }
73 73
74 SerialDeviceEnumerator* SerialServiceImpl::GetDeviceEnumerator() { 74 SerialDeviceEnumerator* SerialServiceImpl::GetDeviceEnumerator() {
75 if (!device_enumerator_) 75 if (!device_enumerator_)
76 device_enumerator_ = SerialDeviceEnumerator::Create(); 76 device_enumerator_ = SerialDeviceEnumerator::Create();
77 return device_enumerator_.get(); 77 return device_enumerator_.get();
78 } 78 }
79 79
80 bool SerialServiceImpl::IsValidPath(const mojo::String& path) { 80 bool SerialServiceImpl::IsValidPath(const mojo::String& path) {
81 mojo::Array<serial::DeviceInfoPtr> devices( 81 mojo::Array<serial::DeviceInfoPtr> devices(
82 GetDeviceEnumerator()->GetDevices()); 82 GetDeviceEnumerator()->GetDevices());
83 for (size_t i = 0; i < devices.size(); i++) { 83 for (size_t i = 0; i < devices.size(); i++) {
84 if (path == devices[i]->path) 84 if (path == devices[i]->path)
85 return true; 85 return true;
86 } 86 }
87 return false; 87 return false;
88 } 88 }
89 89
90 } // namespace device 90 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/serial_service_impl.h ('k') | device/serial/serial_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698