OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/devices_app/devices_app.h" | 5 #include "device/devices_app/devices_app.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 void DevicesApp::Initialize(mojo::Shell* shell, | 83 void DevicesApp::Initialize(mojo::Shell* shell, |
84 const std::string& url, | 84 const std::string& url, |
85 uint32_t id) { | 85 uint32_t id) { |
86 shell_ = shell; | 86 shell_ = shell; |
87 service_initializer_.reset(new USBServiceInitializer); | 87 service_initializer_.reset(new USBServiceInitializer); |
88 StartIdleTimer(); | 88 StartIdleTimer(); |
89 } | 89 } |
90 | 90 |
91 bool DevicesApp::AcceptConnection(mojo::Connection* connection) { | 91 bool DevicesApp::AcceptConnection(mojo::Connection* connection) { |
92 connection->AddService<usb::DeviceManager>(this); | 92 connection->AddInterface<usb::DeviceManager>(this); |
93 return true; | 93 return true; |
94 } | 94 } |
95 | 95 |
96 void DevicesApp::Quit() { | 96 void DevicesApp::Quit() { |
97 service_initializer_.reset(); | 97 service_initializer_.reset(); |
98 shell_ = nullptr; | 98 shell_ = nullptr; |
99 } | 99 } |
100 | 100 |
101 void DevicesApp::Create(mojo::Connection* connection, | 101 void DevicesApp::Create(mojo::Connection* connection, |
102 mojo::InterfaceRequest<usb::DeviceManager> request) { | 102 mojo::InterfaceRequest<usb::DeviceManager> request) { |
103 // Bind the new device manager to the connecting application's permission | 103 // Bind the new device manager to the connecting application's permission |
104 // provider. | 104 // provider. |
105 usb::PermissionProviderPtr permission_provider; | 105 usb::PermissionProviderPtr permission_provider; |
106 connection->ConnectToService(&permission_provider); | 106 connection->GetInterface(&permission_provider); |
107 | 107 |
108 // Owned by its message pipe. | 108 // Owned by its message pipe. |
109 usb::DeviceManagerImpl* device_manager = new usb::DeviceManagerImpl( | 109 usb::DeviceManagerImpl* device_manager = new usb::DeviceManagerImpl( |
110 std::move(permission_provider), std::move(request)); | 110 std::move(permission_provider), std::move(request)); |
111 device_manager->set_connection_error_handler( | 111 device_manager->set_connection_error_handler( |
112 base::Bind(&DevicesApp::OnConnectionError, base::Unretained(this))); | 112 base::Bind(&DevicesApp::OnConnectionError, base::Unretained(this))); |
113 | 113 |
114 active_device_manager_count_++; | 114 active_device_manager_count_++; |
115 idle_timeout_callback_.Cancel(); | 115 idle_timeout_callback_.Cancel(); |
116 } | 116 } |
(...skipping 13 matching lines...) Expand all Loading... |
130 // guaranteed to outlive |this|, and the callback is canceled if |this| is | 130 // guaranteed to outlive |this|, and the callback is canceled if |this| is |
131 // destroyed. | 131 // destroyed. |
132 idle_timeout_callback_.Reset( | 132 idle_timeout_callback_.Reset( |
133 base::Bind(&mojo::Shell::Quit, base::Unretained(shell_))); | 133 base::Bind(&mojo::Shell::Quit, base::Unretained(shell_))); |
134 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 134 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
135 FROM_HERE, idle_timeout_callback_.callback(), | 135 FROM_HERE, idle_timeout_callback_.callback(), |
136 base::TimeDelta::FromSeconds(kIdleTimeoutInSeconds)); | 136 base::TimeDelta::FromSeconds(kIdleTimeoutInSeconds)); |
137 } | 137 } |
138 | 138 |
139 } // namespace device | 139 } // namespace device |
OLD | NEW |