Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: device/devices_app/devices_app.h

Issue 1674903003: Extract shell methods from ApplicationImpl into a base class, and pass this to Initialize() instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojom
Patch Set: . Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/mus/render_widget_mus_connection.cc ('k') | device/devices_app/devices_app.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/cancelable_callback.h" 10 #include "base/cancelable_callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "mojo/shell/public/cpp/application_delegate.h" 14 #include "mojo/shell/public/cpp/application_delegate.h"
15 #include "mojo/shell/public/cpp/interface_factory.h" 15 #include "mojo/shell/public/cpp/interface_factory.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 class ApplicationImpl; 18 class Shell;
19 } 19 }
20 20
21 namespace device { 21 namespace device {
22 22
23 namespace usb { 23 namespace usb {
24 class DeviceManager; 24 class DeviceManager;
25 } 25 }
26 26
27 class DevicesApp : public mojo::ApplicationDelegate, 27 class DevicesApp : public mojo::ApplicationDelegate,
28 public mojo::InterfaceFactory<usb::DeviceManager> { 28 public mojo::InterfaceFactory<usb::DeviceManager> {
29 public: 29 public:
30 DevicesApp(); 30 DevicesApp();
31 ~DevicesApp() override; 31 ~DevicesApp() override;
32 32
33 private: 33 private:
34 class USBServiceInitializer; 34 class USBServiceInitializer;
35 35
36 // mojo::ApplicationDelegate: 36 // mojo::ApplicationDelegate:
37 void Initialize(mojo::ApplicationImpl* app) override; 37 void Initialize(mojo::Shell* shell,
38 const std::string& url,
39 uint32_t id) override;
38 bool AcceptConnection(mojo::ApplicationConnection* connection) override; 40 bool AcceptConnection(mojo::ApplicationConnection* connection) override;
39 void Quit() override; 41 void Quit() override;
40 42
41 // mojo::InterfaceFactory<usb::DeviceManager>: 43 // mojo::InterfaceFactory<usb::DeviceManager>:
42 void Create(mojo::ApplicationConnection* connection, 44 void Create(mojo::ApplicationConnection* connection,
43 mojo::InterfaceRequest<usb::DeviceManager> request) override; 45 mojo::InterfaceRequest<usb::DeviceManager> request) override;
44 46
45 // Mojo error handler to track device manager count. 47 // Mojo error handler to track device manager count.
46 void OnConnectionError(); 48 void OnConnectionError();
47 49
48 // Sets the app for destruction after a period of idle time. If any top-level 50 // Sets the app for destruction after a period of idle time. If any top-level
49 // services (e.g. usb::DeviceManager) are bound before the timeout elapses, 51 // services (e.g. usb::DeviceManager) are bound before the timeout elapses,
50 // it's canceled. 52 // it's canceled.
51 void StartIdleTimer(); 53 void StartIdleTimer();
52 54
53 mojo::ApplicationImpl* app_impl_; 55 mojo::Shell* shell_;
54 scoped_ptr<USBServiceInitializer> service_initializer_; 56 scoped_ptr<USBServiceInitializer> service_initializer_;
55 size_t active_device_manager_count_; 57 size_t active_device_manager_count_;
56 58
57 // Callback used to shut down the app after a period of inactivity. 59 // Callback used to shut down the app after a period of inactivity.
58 base::CancelableClosure idle_timeout_callback_; 60 base::CancelableClosure idle_timeout_callback_;
59 61
60 DISALLOW_COPY_AND_ASSIGN(DevicesApp); 62 DISALLOW_COPY_AND_ASSIGN(DevicesApp);
61 }; 63 };
62 64
63 } // naespace device 65 } // naespace device
64 66
65 #endif // DEVICE_DEVICES_DEVICES_APP_H_ 67 #endif // DEVICE_DEVICES_DEVICES_APP_H_
OLDNEW
« no previous file with comments | « content/renderer/mus/render_widget_mus_connection.cc ('k') | device/devices_app/devices_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698