| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef DEVICE_DEVICES_DEVICES_APP_H_ | |
| 6 #define DEVICE_DEVICES_DEVICES_APP_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include "base/cancelable_callback.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "mojo/shell/public/cpp/interface_factory.h" | |
| 15 #include "mojo/shell/public/cpp/shell_client.h" | |
| 16 | |
| 17 namespace mojo { | |
| 18 class Shell; | |
| 19 } | |
| 20 | |
| 21 namespace device { | |
| 22 | |
| 23 namespace usb { | |
| 24 class DeviceManager; | |
| 25 } | |
| 26 | |
| 27 class DevicesApp : public mojo::ShellClient, | |
| 28 public mojo::InterfaceFactory<usb::DeviceManager> { | |
| 29 public: | |
| 30 DevicesApp(); | |
| 31 ~DevicesApp() override; | |
| 32 | |
| 33 private: | |
| 34 class USBServiceInitializer; | |
| 35 | |
| 36 // mojo::ShellClient: | |
| 37 void Initialize(mojo::Shell* shell, | |
| 38 const std::string& url, | |
| 39 uint32_t id) override; | |
| 40 bool AcceptConnection(mojo::Connection* connection) override; | |
| 41 void Quit() override; | |
| 42 | |
| 43 // mojo::InterfaceFactory<usb::DeviceManager>: | |
| 44 void Create(mojo::Connection* connection, | |
| 45 mojo::InterfaceRequest<usb::DeviceManager> request) override; | |
| 46 | |
| 47 // Mojo error handler to track device manager count. | |
| 48 void OnConnectionError(); | |
| 49 | |
| 50 // Sets the app for destruction after a period of idle time. If any top-level | |
| 51 // services (e.g. usb::DeviceManager) are bound before the timeout elapses, | |
| 52 // it's canceled. | |
| 53 void StartIdleTimer(); | |
| 54 | |
| 55 mojo::Shell* shell_; | |
| 56 scoped_ptr<USBServiceInitializer> service_initializer_; | |
| 57 size_t active_device_manager_count_; | |
| 58 | |
| 59 // Callback used to shut down the app after a period of inactivity. | |
| 60 base::CancelableClosure idle_timeout_callback_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(DevicesApp); | |
| 63 }; | |
| 64 | |
| 65 } // naespace device | |
| 66 | |
| 67 #endif // DEVICE_DEVICES_DEVICES_APP_H_ | |
| OLD | NEW |