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 #ifndef DEVICE_DEVICES_DEVICES_APP_H_ | 5 #ifndef DEVICE_DEVICES_DEVICES_APP_H_ |
6 #define DEVICE_DEVICES_DEVICES_APP_H_ | 6 #define DEVICE_DEVICES_DEVICES_APP_H_ |
7 | 7 |
8 #include "base/cancelable_callback.h" | 8 #include "base/cancelable_callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "mojo/application/public/cpp/application_delegate.h" | 12 #include "mojo/application/public/cpp/application_delegate.h" |
13 #include "mojo/application/public/cpp/interface_factory.h" | 13 #include "mojo/application/public/cpp/interface_factory.h" |
14 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h" | 14 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h" |
Ken Rockot(use gerrit already)
2015/07/10 15:40:58
nit: Please remove this too
leonhsl(Using Gerrit)
2015/07/10 16:20:48
Done.
| |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class SequencedTaskRunner; | 17 class SequencedTaskRunner; |
18 } | 18 } |
19 | 19 |
20 namespace mojo { | 20 namespace mojo { |
21 class ApplicationImpl; | 21 class ApplicationImpl; |
22 } | 22 } |
23 | 23 |
24 namespace device { | 24 namespace device { |
25 | 25 |
26 namespace usb { | 26 namespace usb { |
27 class DeviceManager; | 27 class DeviceManager; |
28 } | 28 } |
29 | 29 |
30 class DevicesApp : public mojo::ApplicationDelegate, | 30 class DevicesApp : public mojo::ApplicationDelegate, |
31 public mojo::InterfaceFactory<usb::DeviceManager>, | 31 public mojo::InterfaceFactory<usb::DeviceManager> { |
32 public mojo::ErrorHandler { | |
33 public: | 32 public: |
34 explicit DevicesApp( | 33 explicit DevicesApp( |
35 scoped_refptr<base::SequencedTaskRunner> service_task_runner); | 34 scoped_refptr<base::SequencedTaskRunner> service_task_runner); |
36 ~DevicesApp() override; | 35 ~DevicesApp() override; |
37 | 36 |
38 private: | 37 private: |
39 class USBServiceInitializer; | 38 class USBServiceInitializer; |
40 | 39 |
41 // mojo::ApplicationDelegate: | 40 // mojo::ApplicationDelegate: |
42 void Initialize(mojo::ApplicationImpl* app) override; | 41 void Initialize(mojo::ApplicationImpl* app) override; |
43 bool ConfigureIncomingConnection( | 42 bool ConfigureIncomingConnection( |
44 mojo::ApplicationConnection* connection) override; | 43 mojo::ApplicationConnection* connection) override; |
45 void Quit() override; | 44 void Quit() override; |
46 | 45 |
47 // mojo::InterfaceFactory<usb::DeviceManager>: | 46 // mojo::InterfaceFactory<usb::DeviceManager>: |
48 void Create(mojo::ApplicationConnection* connection, | 47 void Create(mojo::ApplicationConnection* connection, |
49 mojo::InterfaceRequest<usb::DeviceManager> request) override; | 48 mojo::InterfaceRequest<usb::DeviceManager> request) override; |
50 | 49 |
51 // mojo::ErrorHandler: | 50 // Mojo error handler to track device manager count. |
52 void OnConnectionError() override; | 51 void OnConnectionError(); |
53 | 52 |
54 // Sets the app for destruction after a period of idle time. If any top-level | 53 // Sets the app for destruction after a period of idle time. If any top-level |
55 // services (e.g. usb::DeviceManager) are bound before the timeout elapses, | 54 // services (e.g. usb::DeviceManager) are bound before the timeout elapses, |
56 // it's canceled. | 55 // it's canceled. |
57 void StartIdleTimer(); | 56 void StartIdleTimer(); |
58 | 57 |
59 mojo::ApplicationImpl* app_impl_; | 58 mojo::ApplicationImpl* app_impl_; |
60 scoped_ptr<USBServiceInitializer> service_initializer_; | 59 scoped_ptr<USBServiceInitializer> service_initializer_; |
61 scoped_refptr<base::SequencedTaskRunner> service_task_runner_; | 60 scoped_refptr<base::SequencedTaskRunner> service_task_runner_; |
62 size_t active_device_manager_count_; | 61 size_t active_device_manager_count_; |
63 | 62 |
64 // Callback used to shut down the app after a period of inactivity. | 63 // Callback used to shut down the app after a period of inactivity. |
65 base::CancelableClosure idle_timeout_callback_; | 64 base::CancelableClosure idle_timeout_callback_; |
66 | 65 |
67 DISALLOW_COPY_AND_ASSIGN(DevicesApp); | 66 DISALLOW_COPY_AND_ASSIGN(DevicesApp); |
68 }; | 67 }; |
69 | 68 |
70 } // naespace device | 69 } // naespace device |
71 | 70 |
72 #endif // DEVICE_DEVICES_DEVICES_APP_H_ | 71 #endif // DEVICE_DEVICES_DEVICES_APP_H_ |
OLD | NEW |