| 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> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 12 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 13 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 14 #include "device/core/device_client.h" | 16 #include "device/core/device_client.h" |
| 15 #include "device/devices_app/usb/device_manager_impl.h" | 17 #include "device/devices_app/usb/device_manager_impl.h" |
| 16 #include "device/usb/usb_service.h" | 18 #include "device/usb/usb_service.h" |
| 17 #include "mojo/application/public/cpp/application_connection.h" | 19 #include "mojo/application/public/cpp/application_connection.h" |
| 18 #include "mojo/application/public/cpp/application_impl.h" | 20 #include "mojo/application/public/cpp/application_impl.h" |
| 19 #include "mojo/public/cpp/bindings/interface_request.h" | 21 #include "mojo/public/cpp/bindings/interface_request.h" |
| 20 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 21 | 23 |
| 22 namespace device { | 24 namespace device { |
| 23 | 25 |
| 24 namespace { | 26 namespace { |
| 25 | 27 |
| 26 // The number of seconds to wait without any bound DeviceManagers before | 28 // The number of seconds to wait without any bound DeviceManagers before |
| 27 // exiting the app. | 29 // exiting the app. |
| 28 const int64 kIdleTimeoutInSeconds = 10; | 30 const int64_t kIdleTimeoutInSeconds = 10; |
| 29 | 31 |
| 30 // A DeviceClient implementation to be constructed iff the app is not running | 32 // A DeviceClient implementation to be constructed iff the app is not running |
| 31 // in an embedder that provides a DeviceClient (i.e. running as a standalone | 33 // in an embedder that provides a DeviceClient (i.e. running as a standalone |
| 32 // Mojo app, not in Chrome). | 34 // Mojo app, not in Chrome). |
| 33 class AppDeviceClient : public DeviceClient { | 35 class AppDeviceClient : public DeviceClient { |
| 34 public: | 36 public: |
| 35 explicit AppDeviceClient( | 37 explicit AppDeviceClient( |
| 36 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) | 38 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) |
| 37 : blocking_task_runner_(blocking_task_runner) {} | 39 : blocking_task_runner_(blocking_task_runner) {} |
| 38 ~AppDeviceClient() override {} | 40 ~AppDeviceClient() override {} |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // guaranteed to outlive |this|, and the callback is canceled if |this| is | 129 // guaranteed to outlive |this|, and the callback is canceled if |this| is |
| 128 // destroyed. | 130 // destroyed. |
| 129 idle_timeout_callback_.Reset(base::Bind(&mojo::ApplicationImpl::Quit, | 131 idle_timeout_callback_.Reset(base::Bind(&mojo::ApplicationImpl::Quit, |
| 130 base::Unretained(app_impl_))); | 132 base::Unretained(app_impl_))); |
| 131 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 133 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 132 FROM_HERE, idle_timeout_callback_.callback(), | 134 FROM_HERE, idle_timeout_callback_.callback(), |
| 133 base::TimeDelta::FromSeconds(kIdleTimeoutInSeconds)); | 135 base::TimeDelta::FromSeconds(kIdleTimeoutInSeconds)); |
| 134 } | 136 } |
| 135 | 137 |
| 136 } // namespace device | 138 } // namespace device |
| OLD | NEW |