ui: ozone: add missing files to GN build
[chromium-blink-merge.git] / device / devices_app / devices_app.h
blobcac12f4d7fcf9dc11b80e4c0e0b9e7c66372a4fe
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
3 // found in the LICENSE file.
5 #ifndef DEVICE_DEVICES_DEVICES_APP_H_
6 #define DEVICE_DEVICES_DEVICES_APP_H_
8 #include "base/cancelable_callback.h"
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "mojo/application/public/cpp/application_delegate.h"
13 #include "mojo/application/public/cpp/interface_factory.h"
15 namespace base {
16 class SequencedTaskRunner;
19 namespace mojo {
20 class ApplicationImpl;
23 namespace device {
25 namespace usb {
26 class DeviceManager;
29 class DevicesApp : public mojo::ApplicationDelegate,
30 public mojo::InterfaceFactory<usb::DeviceManager> {
31 public:
32 explicit DevicesApp(
33 scoped_refptr<base::SequencedTaskRunner> service_task_runner);
34 ~DevicesApp() override;
36 private:
37 class USBServiceInitializer;
39 // mojo::ApplicationDelegate:
40 void Initialize(mojo::ApplicationImpl* app) override;
41 bool ConfigureIncomingConnection(
42 mojo::ApplicationConnection* connection) override;
43 void Quit() override;
45 // mojo::InterfaceFactory<usb::DeviceManager>:
46 void Create(mojo::ApplicationConnection* connection,
47 mojo::InterfaceRequest<usb::DeviceManager> request) override;
49 // Mojo error handler to track device manager count.
50 void OnConnectionError();
52 // Sets the app for destruction after a period of idle time. If any top-level
53 // services (e.g. usb::DeviceManager) are bound before the timeout elapses,
54 // it's canceled.
55 void StartIdleTimer();
57 mojo::ApplicationImpl* app_impl_;
58 scoped_ptr<USBServiceInitializer> service_initializer_;
59 scoped_refptr<base::SequencedTaskRunner> service_task_runner_;
60 size_t active_device_manager_count_;
62 // Callback used to shut down the app after a period of inactivity.
63 base::CancelableClosure idle_timeout_callback_;
65 DISALLOW_COPY_AND_ASSIGN(DevicesApp);
68 } // naespace device
70 #endif // DEVICE_DEVICES_DEVICES_APP_H_