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

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

Issue 1475563002: arc-bridge: Implement IPC message for app launcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use creator for ArcBridgeService Created 5 years 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 "components/arc/arc_bridge_service.h"
11 #include "ipc/ipc_channel_proxy.h"
12 #include "ipc/ipc_listener.h"
13 #include "ipc/ipc_message.h"
14
15 namespace base {
16 class SequencedTaskRunner;
17 class SingleThreadTaskRunner;
18 }
19
20 namespace arc {
21
22 // Real IPC based ArcBridgeService that is used in production.
23 class ArcBridgeServiceImpl : public ArcBridgeService,
24 public IPC::Listener {
25 public:
26
hidehiko 2015/11/25 07:47:37 Unnecessary space.
khmel1 2015/11/25 15:28:31 Done.
hidehiko 2015/11/26 03:47:22 Not done yet.
khmel1 2015/11/27 05:24:01 Was done in prev CL. updated here
27 ArcBridgeServiceImpl(
28 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
29 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner);
30 ~ArcBridgeServiceImpl() override;
31
32 void DetectAvailability() override;
33
34 void HandleStartup() override;
35
36 void Shutdown() override;
37
38 bool RegisterInputDevice(const std::string& name,
39 const std::string& device_type,
40 base::ScopedFD fd) override;
41
42 // Requests to refresh an app list.
43 bool RefreshApps() override;
44
45 // Requests to launch an app.
46 bool LaunchApp(const std::string& package,
47 const std::string& activity) override;
48
49 // Request to load icon of specific scale_factor.
50 bool RequestIcon(const std::string& package,
51 const std::string& activity,
52 int scale_factor) override;
53
54 private:
55 friend class ArcBridgeTest;
56 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic);
57 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup);
58
59 // If all pre-requisites are true (ARC is available, it has been enabled, and
60 // the session has started), and ARC is stopped, start ARC. If ARC is running
61 // and the pre-requisites stop being true, stop ARC.
62 void PrerequisitesChanged();
63
64 // Binds to the socket specified by |socket_path|.
65 void SocketConnect(const base::FilePath& socket_path);
66
67 // Binds to the socket specified by |socket_path| after creating its parent
68 // directory is present.
69 void SocketConnectAfterEnsureParentDirectory(
70 const base::FilePath& socket_path,
71 bool directory_present);
72
73 // Internal connection method. Separated to make testing easier.
74 bool Connect(const IPC::ChannelHandle& handle, IPC::Channel::Mode mode);
75
76 // Finishes connecting after setting socket permissions.
77 void SocketConnectAfterSetSocketPermissions(const base::FilePath& socket_path,
78 bool socket_permissions_success);
79
80 // Stops the running instance.
81 void StopInstance();
82
83 // Called when the instance has reached a boot phase
84 void OnInstanceBootPhase(InstanceBootPhase phase);
85
86 // Called whenever ARC sends information about available apps.
87 void OnAppsRefreshed(const std::vector<std::string>& name,
88 const std::vector<std::string>& packages,
89 const std::vector<std::string>& activities);
90
91 // Called whenever ARC sends app icon data for specific scale factor.
92 void OnAppIcon(const std::string& package,
93 const std::string& activity,
94 int scale_factor,
95 const std::vector<uint8_t>& icon_png_data);
96
97 // IPC::Listener:
98 bool OnMessageReceived(const IPC::Message& message) override;
99
100 // DBus callbacks.
101 void OnArcAvailable(bool available);
102 void OnInstanceStarted(bool success);
103 void OnInstanceStopped(bool success);
104
105 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_;
106 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
107
108 scoped_ptr<IPC::ChannelProxy> ipc_channel_;
109
110 // If the user's session has started.
111 bool session_started_;
112
113 // WeakPtrFactory to use callbacks.
114 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_;
115
116 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl);
117 };
118
119 } // namespace arc
120
121 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698