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

Side by Side Diff: components/arc/arc_bridge_service_impl.h

Issue 1413153007: arc-app-launcher: Minimal support for ARC app launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit comments addressed Created 5 years, 1 month 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
OLDNEW
(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 COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_
6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_
7
8 #include "base/files/scoped_file.h"
9 #include "base/macros.h"
10 #include "base/sequenced_task_runner.h"
11 #include "components/arc/arc_bridge_service.h"
12 #include "ipc/ipc_channel_proxy.h"
13 #include "ipc/ipc_listener.h"
14 #include "ipc/ipc_message.h"
15
16 namespace arc {
17
18 // Real IPC based ArcBridgeService that is used in production.
19 class ArcBridgeServiceImpl : public ArcBridgeService, public IPC::Listener {
xiyuan 2015/11/18 17:41:15 nit: move "public IPC::Listener" to its own line.
khmel1 2015/11/19 02:56:13 Done.
20 public:
21
22 ArcBridgeServiceImpl(
23 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
24 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner);
25 ~ArcBridgeServiceImpl() override;
26
27 // DetectAvailability() should be called once D-Bus is available. It will
28 // call CheckArcAvailability() on the session_manager. This can only be
29 // called on the thread that this class was created on.
30 void DetectAvailability();
31
32 void HandleStartup() override;
33
34 void Shutdown() override;
35
36 bool RegisterInputDevice(const std::string& name,
37 const std::string& device_type,
38 base::ScopedFD fd) override;
39 // Requests to refresh an app list.
Luis Héctor Chávez 2015/11/18 18:22:19 nit: Be consistent with the spacing. Add a newline
khmel1 2015/11/19 02:56:13 Done.
40 bool RefreshApps() override;
41
42 // Requests to launch an app.
43 bool LaunchApp(const std::string& package,
44 const std::string& activity) override;
45
46 // Request to load icon of specific scale_factor.
47 bool RequestIcon(const std::string& package,
48 const std::string& activity,
49 int scale_factor) override;
50
51 private:
52 friend class ArcBridgeTest;
53 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic);
54 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup);
55
56 // If all pre-requisites are true (ARC is available, it has been enabled, and
57 // the session has started), and ARC is stopped, start ARC. If ARC is running
58 // and the pre-requisites stop being true, stop ARC.
59 void PrerequisitesChanged();
60
61 // Binds to the socket specified by |socket_path|.
62 void SocketConnect(const base::FilePath& socket_path);
63
64 // Binds to the socket specified by |socket_path| after creating its parent
65 // directory is present.
66 void SocketConnectAfterEnsureParentDirectory(
67 const base::FilePath& socket_path,
68 bool directory_present);
69
70 // Internal connection method. Separated to make testing easier.
71 bool Connect(const IPC::ChannelHandle& handle, IPC::Channel::Mode mode);
72
73 // Finishes connecting after setting socket permissions.
74 void SocketConnectAfterSetSocketPermissions(const base::FilePath& socket_path,
75 bool socket_permissions_success);
76
77 // Stops the running instance.
78 void StopInstance();
79
80 // Called when the ARC instance has finished setting up and is ready for user
81 // interaction.
82 void OnInstanceReady();
83
84 // Called whenever ARC sends information about available apps.
85 void OnAppsRefreshed(const std::vector<std::string>& name,
86 const std::vector<std::string>& packages,
87 const std::vector<std::string>& activities);
88
89 // Called whenever ARC sends app icon data for specific scale factor.
90 void OnAppIcon(const std::string& package,
91 const std::string& activity,
92 int scale_factor,
93 const std::vector<uint8_t>& icon_png_data);
94
95 // IPC::Listener:
96 bool OnMessageReceived(const IPC::Message& message) override;
97
98 // DBus callbacks.
99 void OnArcAvailable(bool available);
100 void OnInstanceStarted(bool success);
101 void OnInstanceStopped(bool success);
102
103 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_;
104 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
105
106 scoped_ptr<IPC::ChannelProxy> ipc_channel_;
107
108 // If the user's session has started.
109 bool session_started_;
110
111 // WeakPtrFactory to use callbacks.
112 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_;
113
114 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl);
115 };
116
117 } // namespace arc
118
119 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698