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

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

Issue 380413003: Mojo: Use InterfaceFactory<Interface> for service registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix network_service_loader Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « device/serial/serial_service_impl.h ('k') | mojo/cc/context_provider_mojo.h » ('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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (!IsValidPath(path)) 59 if (!IsValidPath(path))
60 return; 60 return;
61 connection_factory_->CreateConnection( 61 connection_factory_->CreateConnection(
62 path, options.Pass(), connection_request.Pass()); 62 path, options.Pass(), connection_request.Pass());
63 } 63 }
64 64
65 void SerialServiceImpl::OnConnectionError() {
66 delete this;
67 }
68
69 SerialDeviceEnumerator* SerialServiceImpl::GetDeviceEnumerator() { 65 SerialDeviceEnumerator* SerialServiceImpl::GetDeviceEnumerator() {
70 if (!device_enumerator_) 66 if (!device_enumerator_)
71 device_enumerator_ = SerialDeviceEnumerator::Create(); 67 device_enumerator_ = SerialDeviceEnumerator::Create();
72 return device_enumerator_.get(); 68 return device_enumerator_.get();
73 } 69 }
74 70
75 bool SerialServiceImpl::IsValidPath(const mojo::String& path) { 71 bool SerialServiceImpl::IsValidPath(const mojo::String& path) {
76 mojo::Array<serial::DeviceInfoPtr> devices( 72 mojo::Array<serial::DeviceInfoPtr> devices(
77 GetDeviceEnumerator()->GetDevices()); 73 GetDeviceEnumerator()->GetDevices());
78 for (size_t i = 0; i < devices.size(); i++) { 74 for (size_t i = 0; i < devices.size(); i++) {
79 if (path == devices[i]->path) 75 if (path == devices[i]->path)
80 return true; 76 return true;
81 } 77 }
82 return false; 78 return false;
83 } 79 }
84 80
85 void SerialServiceImpl::OnConnected( 81 void SerialServiceImpl::OnConnected(
86 const mojo::Callback<void(serial::ConnectionInfoPtr)>& callback, 82 const mojo::Callback<void(serial::ConnectionInfoPtr)>& callback,
87 serial::ConnectionInfoPtr result) { 83 serial::ConnectionInfoPtr result) {
88 callback.Run(result.Pass()); 84 callback.Run(result.Pass());
89 } 85 }
90 86
91 } // namespace device 87 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/serial_service_impl.h ('k') | mojo/cc/context_provider_mojo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698