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

Unified Diff: components/arc/arc_bridge_service_impl.cc

Issue 1475583002: Add IPC messages for ARC notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments 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 side-by-side diff with in-line comments
Download patch
Index: components/arc/arc_bridge_service_impl.cc
diff --git a/components/arc/arc_bridge_service_impl.cc b/components/arc/arc_bridge_service_impl.cc
index 1a1c954fefa2993b44ff387ae762c8cc6c9597a2..4975075d2651945671f4b14ef5d415d6ba69e2a8 100644
--- a/components/arc/arc_bridge_service_impl.cc
+++ b/components/arc/arc_bridge_service_impl.cc
@@ -100,12 +100,19 @@ bool ArcBridgeServiceImpl::RegisterInputDevice(const std::string& name,
const std::string& device_type,
base::ScopedFD fd) {
DCHECK(origin_task_runner()->RunsTasksOnCurrentThread());
- if (state() != State::READY) {
- LOG(ERROR) << "Called RegisterInputDevice when the service is not ready";
+ return SendMessageIfReady(new ArcInstanceMsg_RegisterInputDevice(
+ name, device_type, base::FileDescriptor(fd.Pass())));
+}
+
+bool ArcBridgeServiceImpl::SendNotificationEventToAndroid(
+ const std::string& key, ArcNotificationEvent event) {
+ DCHECK(ipc_task_runner_->RunsTasksOnCurrentThread());
+ if (key.empty()) {
+ LOG(ERROR) << "NotifyNotificationEvent failed: Wrong parameter";
elijahtaylor1 2015/12/01 07:02:36 method rename in log message
yoshiki 2015/12/02 02:38:24 Done.
return false;
}
- return ipc_channel_->Send(new ArcInstanceMsg_RegisterInputDevice(
- name, device_type, base::FileDescriptor(fd.Pass())));
+ return SendMessageIfReady(
+ new ArcInstanceMsg_NotifyNotificationEvent(key, event));
elijahtaylor1 2015/12/01 07:02:36 I think the method name change should go all the w
yoshiki 2015/12/02 02:38:24 Done.
}
void ArcBridgeServiceImpl::SocketConnect(const base::FilePath& socket_path) {
@@ -192,6 +199,15 @@ void ArcBridgeServiceImpl::SocketConnectAfterSetSocketPermissions(
weak_factory_.GetWeakPtr()));
}
+bool ArcBridgeServiceImpl::SendMessageIfReady(IPC::Message* message) {
+ DCHECK(ipc_task_runner_->RunsTasksOnCurrentThread());
+ if (state() != State::READY) {
+ LOG(ERROR) << "Tried to send a message but the service is not ready";
elijahtaylor1 2015/12/01 07:02:36 too bad we lose the actual method name here, is th
yoshiki 2015/12/02 02:38:24 Let me revert back here to the original. I think c
+ return false;
+ }
+ return ipc_channel_->Send(message);
+}
+
void ArcBridgeServiceImpl::OnInstanceStarted(bool success) {
DCHECK(origin_task_runner()->RunsTasksOnCurrentThread());
if (state() != State::STARTING) {
@@ -219,6 +235,20 @@ void ArcBridgeServiceImpl::OnInstanceBootPhase(InstanceBootPhase phase) {
FOR_EACH_OBSERVER(Observer, observer_list(), OnInstanceBootPhase(phase));
}
+void ArcBridgeServiceImpl::OnNotificationPostedFromAndroid(
+ const arc::ArcNotificationData& data) {
+ DCHECK(origin_task_runner()->RunsTasksOnCurrentThread());
+ FOR_EACH_OBSERVER(Observer, observer_list(),
+ OnNotificationPostedFromAndroid(data));
+}
+
+void ArcBridgeServiceImpl::OnNotificationRemovedFromAndroid(
+ const std::string& key) {
+ DCHECK(origin_task_runner()->RunsTasksOnCurrentThread());
+ FOR_EACH_OBSERVER(Observer, observer_list(),
+ OnNotificationRemovedFromAndroid(key));
+}
+
bool ArcBridgeServiceImpl::OnMessageReceived(const IPC::Message& message) {
DCHECK(origin_task_runner()->RunsTasksOnCurrentThread());
bool handled = true;
@@ -226,6 +256,10 @@ bool ArcBridgeServiceImpl::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(ArcBridgeServiceImpl, message)
IPC_MESSAGE_HANDLER(ArcInstanceHostMsg_InstanceBootPhase,
OnInstanceBootPhase)
+ IPC_MESSAGE_HANDLER(ArcInstanceHostMsg_NotificationPosted,
+ OnNotificationPostedFromAndroid)
+ IPC_MESSAGE_HANDLER(ArcInstanceHostMsg_NotificationRemoved,
+ OnNotificationRemovedFromAndroid)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()

Powered by Google App Engine
This is Rietveld 408576698