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

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

Issue 1475583002: Add IPC messages for ARC notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed the comments 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
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 COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ 5 #ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ 6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
7 7
8 #include "base/files/scoped_file.h" 8 #include "base/files/scoped_file.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "components/arc/common/arc_message_types.h" 12 #include "components/arc/common/arc_message_types.h"
13 #include "components/arc/common/arc_notification_types.h"
13 14
14 namespace base { 15 namespace base {
15 class CommandLine; 16 class CommandLine;
16 class SequencedTaskRunner; 17 class SequencedTaskRunner;
17 class SingleThreadTaskRunner; 18 class SingleThreadTaskRunner;
18 } // namespace base 19 } // namespace base
19 20
20 namespace arc { 21 namespace arc {
21 22
22 // The Chrome-side service that handles ARC instances and ARC bridge creation. 23 // The Chrome-side service that handles ARC instances and ARC bridge creation.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Called when the instance has reached a boot phase 73 // Called when the instance has reached a boot phase
73 virtual void OnInstanceBootPhase(InstanceBootPhase phase) {} 74 virtual void OnInstanceBootPhase(InstanceBootPhase phase) {}
74 75
75 // Called whenever ARC's availability has changed for this system. 76 // Called whenever ARC's availability has changed for this system.
76 virtual void OnAvailableChanged(bool available) {} 77 virtual void OnAvailableChanged(bool available) {}
77 78
78 protected: 79 protected:
79 virtual ~Observer() {} 80 virtual ~Observer() {}
80 }; 81 };
81 82
83 class NotificationObserver {
dcheng 2015/12/02 18:26:53 With https://codereview.chromium.org/1475563002, t
yoshiki 2015/12/03 14:17:55 Yes, and we'll have more type of observers, but I
84 public:
85 // Called whenever a notification has been posted on Android side. This
86 // event is used for both creation and update.
87 virtual void OnNotificationPostedFromAndroid(
88 const ArcNotificationData& data) {}
89 // Called whenever a notification has been removed on Android side.
90 virtual void OnNotificationRemovedFromAndroid(const std::string& key) {}
91
92 protected:
93 virtual ~NotificationObserver() {}
94 };
95
82 virtual ~ArcBridgeService(); 96 virtual ~ArcBridgeService();
83 97
84 // Creates instance of |ArcBridgeService| for normal use. 98 // Creates instance of |ArcBridgeService| for normal use.
85 static scoped_ptr<ArcBridgeService> Create( 99 static scoped_ptr<ArcBridgeService> Create(
86 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, 100 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
87 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner); 101 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner);
88 102
89 // Gets the global instance of the ARC Bridge Service. This can only be 103 // Gets the global instance of the ARC Bridge Service. This can only be
90 // called on the thread that this class was created on. 104 // called on the thread that this class was created on.
91 static ArcBridgeService* Get(); 105 static ArcBridgeService* Get();
(...skipping 13 matching lines...) Expand all
105 virtual void HandleStartup() = 0; 119 virtual void HandleStartup() = 0;
106 120
107 // Shutdown() should be called when the browser is shutting down. This can 121 // Shutdown() should be called when the browser is shutting down. This can
108 // only be called on the thread that this class was created on. 122 // only be called on the thread that this class was created on.
109 virtual void Shutdown() = 0; 123 virtual void Shutdown() = 0;
110 124
111 // Adds or removes observers. This can only be called on the thread that this 125 // Adds or removes observers. This can only be called on the thread that this
112 // class was created on. 126 // class was created on.
113 void AddObserver(Observer* observer); 127 void AddObserver(Observer* observer);
114 void RemoveObserver(Observer* observer); 128 void RemoveObserver(Observer* observer);
129 void AddNotificationObserver(NotificationObserver* observer);
130 void RemoveNotificationObserver(NotificationObserver* observer);
115 131
116 // Gets the current state of the bridge service. 132 // Gets the current state of the bridge service.
117 State state() const { return state_; } 133 State state() const { return state_; }
118 134
119 // Gets if ARC is available in this system. 135 // Gets if ARC is available in this system.
120 bool available() const { return available_; } 136 bool available() const { return available_; }
121 137
122 // Requests registration of an input device on the ARC instance. 138 // Requests registration of an input device on the ARC instance.
123 // TODO(denniskempin): Make this interface more typesafe. 139 // TODO(denniskempin): Make this interface more typesafe.
124 // |name| should be the displayable name of the emulated device (e.g. "Chrome 140 // |name| should be the displayable name of the emulated device (e.g. "Chrome
125 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard") 141 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard")
126 // and |fd| a file descriptor that emulates the kernel events of the device. 142 // and |fd| a file descriptor that emulates the kernel events of the device.
127 // This can only be called on the thread that this class was created on. 143 // This can only be called on the thread that this class was created on.
128 virtual bool RegisterInputDevice(const std::string& name, 144 virtual bool RegisterInputDevice(const std::string& name,
129 const std::string& device_type, 145 const std::string& device_type,
130 base::ScopedFD fd) = 0; 146 base::ScopedFD fd) = 0;
131 147
148 // Sends a notification event to Android side.
149 virtual bool SendNotificationEventToAndroid(const std::string& key,
150 ArcNotificationEvent event) = 0;
151
132 protected: 152 protected:
133 ArcBridgeService(); 153 ArcBridgeService();
134 154
135 // Changes the current state and notifies all observers. 155 // Changes the current state and notifies all observers.
136 void SetState(State state); 156 void SetState(State state);
137 157
138 // Changes the current availability and notifies all observers. 158 // Changes the current availability and notifies all observers.
139 void SetAvailable(bool availability); 159 void SetAvailable(bool availability);
140 160
141 const scoped_refptr<base::SequencedTaskRunner>& origin_task_runner() const { 161 const scoped_refptr<base::SequencedTaskRunner>& origin_task_runner() const {
142 return origin_task_runner_; 162 return origin_task_runner_;
143 } 163 }
144 164
145 base::ObserverList<Observer>& observer_list() { return observer_list_; } 165 base::ObserverList<Observer>& observer_list() { return observer_list_; }
166 base::ObserverList<NotificationObserver>& notification_observer_list() {
167 return notification_observer_list_;
168 }
146 169
147 private: 170 private:
148 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_; 171 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_;
149 172
150 base::ObserverList<Observer> observer_list_; 173 base::ObserverList<Observer> observer_list_;
174 base::ObserverList<NotificationObserver> notification_observer_list_;
151 175
152 // If the ARC instance service is available. 176 // If the ARC instance service is available.
153 bool available_; 177 bool available_;
154 178
155 // The current state of the bridge. 179 // The current state of the bridge.
156 ArcBridgeService::State state_; 180 ArcBridgeService::State state_;
157 181
158 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); 182 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService);
159 }; 183 };
160 184
161 } // namespace arc 185 } // namespace arc
162 186
163 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ 187 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698