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

Unified Diff: components/arc/arc_bridge_service_impl.cc

Issue 1523643002: arc-bridge: Move most methods to Mojo interfaces (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Fixed unit tests 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 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 ddd1b6aeb8aaa59269115aa640f56a0d8e0305f5..da56cde1f600c6e1bf66bdcdb9c5b7ccbb319896 100644
--- a/components/arc/arc_bridge_service_impl.cc
+++ b/components/arc/arc_bridge_service_impl.cc
@@ -17,19 +17,6 @@
#include "chromeos/dbus/dbus_method_call_status.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
-#include "mojo/public/cpp/bindings/array.h"
-#include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
-
-namespace mojo {
-
-template <>
-struct TypeConverter<arc::AppInfo, arc::AppInfoPtr> {
- static arc::AppInfo Convert(const arc::AppInfoPtr& app_info_ptr) {
- return *app_info_ptr;
- }
-};
-
-} // namespace mojo
namespace arc {
@@ -89,130 +76,56 @@ void ArcBridgeServiceImpl::StopInstance() {
bootstrap_->Stop();
}
-bool ArcBridgeServiceImpl::RegisterInputDevice(const std::string& name,
- const std::string& device_type,
- base::ScopedFD fd) {
+void ArcBridgeServiceImpl::OnAppInstanceReady(AppInstancePtr app_ptr) {
DCHECK(CalledOnValidThread());
if (state() != State::READY) {
- LOG(ERROR) << "Called RegisterInputDevice when the service is not ready";
- return false;
- }
- MojoHandle wrapped_handle;
- MojoResult wrap_result = mojo::embedder::CreatePlatformHandleWrapper(
- mojo::embedder::ScopedPlatformHandle(
- mojo::embedder::PlatformHandle(fd.release())),
- &wrapped_handle);
- if (wrap_result != MOJO_RESULT_OK) {
- LOG(WARNING) << "Pipe failed to wrap handles. Closing: " << wrap_result;
- return false;
+ VLOG(1) << "StopInstance() called";
+ return;
}
- instance_ptr_->RegisterInputDevice(
- name, device_type, mojo::ScopedHandle(mojo::Handle(wrapped_handle)));
- return true;
+ app_ptr_ = std::move(app_ptr);
+ FOR_EACH_OBSERVER(Observer, observer_list(), OnAppInstanceReady());
}
-bool ArcBridgeServiceImpl::SendNotificationEventToAndroid(
- const std::string& key, ArcNotificationEvent event) {
+void ArcBridgeServiceImpl::OnInputInstanceReady(InputInstancePtr input_ptr) {
DCHECK(CalledOnValidThread());
- if (key.empty()) {
- LOG(ERROR) << "SendNotificationToAndroid failed: Wrong parameter";
- return false;
- }
if (state() != State::READY) {
- LOG(ERROR) << "Called SendNotificationEventToAndroid when the service is"
- << "not ready";
- return false;
+ VLOG(1) << "StopInstance() called";
+ return;
}
- instance_ptr_->SendNotificationEventToAndroid(key, event);
- return true;
+ input_ptr_ = std::move(input_ptr);
+ FOR_EACH_OBSERVER(Observer, observer_list(), OnInputInstanceReady());
}
-bool ArcBridgeServiceImpl::RefreshAppList() {
+void ArcBridgeServiceImpl::OnNotificationsInstanceReady(
+ NotificationsInstancePtr notifications_ptr) {
DCHECK(CalledOnValidThread());
if (state() != State::READY) {
- LOG(ERROR) << "Called RefreshAppList when the service is not ready";
- return false;
+ VLOG(1) << "StopInstance() called";
+ return;
}
- instance_ptr_->RefreshAppList();
- return true;
+ notifications_ptr_ = std::move(notifications_ptr);
+ FOR_EACH_OBSERVER(Observer, observer_list(), OnNotificationsInstanceReady());
}
-bool ArcBridgeServiceImpl::LaunchApp(const std::string& package,
- const std::string& activity) {
+void ArcBridgeServiceImpl::OnPowerInstanceReady(PowerInstancePtr power_ptr) {
DCHECK(CalledOnValidThread());
if (state() != State::READY) {
- LOG(ERROR) << "Called LaunchApp when the service is not ready";
- return false;
+ VLOG(1) << "StopInstance() called";
+ return;
}
- instance_ptr_->LaunchApp(package, activity);
- return true;
+ power_ptr_ = std::move(power_ptr);
+ FOR_EACH_OBSERVER(Observer, observer_list(), OnPowerInstanceReady());
}
-bool ArcBridgeServiceImpl::RequestAppIcon(const std::string& package,
- const std::string& activity,
- ScaleFactor scale_factor) {
+void ArcBridgeServiceImpl::OnProcessListInstanceReady(
+ ProcessListInstancePtr process_list_ptr) {
DCHECK(CalledOnValidThread());
if (state() != State::READY) {
- LOG(ERROR) << "Called RequestAppIcon when the service is not ready";
- return false;
- }
- instance_ptr_->RequestAppIcon(package, activity, scale_factor);
- return true;
-}
-
-void ArcBridgeServiceImpl::OnInstanceBootPhase(InstanceBootPhase phase) {
- DCHECK(CalledOnValidThread());
- // The state can be CONNECTED the first time this is called, and will then
- // transition to READY after BRIDGE_READY has been passed.
- if (state() != State::CONNECTED && state() != State::READY) {
- VLOG(1) << "StopInstance() called while connecting";
+ VLOG(1) << "StopInstance() called";
return;
}
- if (phase == INSTANCE_BOOT_PHASE_BRIDGE_READY) {
- SetState(State::READY);
- }
- FOR_EACH_OBSERVER(Observer, observer_list(), OnInstanceBootPhase(phase));
-}
-
-void ArcBridgeServiceImpl::OnNotificationPosted(ArcNotificationDataPtr data) {
- DCHECK(CalledOnValidThread());
- FOR_EACH_OBSERVER(NotificationObserver, notification_observer_list(),
- OnNotificationPostedFromAndroid(*data.get()));
-}
-
-void ArcBridgeServiceImpl::OnNotificationRemoved(const mojo::String& key) {
- DCHECK(CalledOnValidThread());
- FOR_EACH_OBSERVER(NotificationObserver, notification_observer_list(),
- OnNotificationRemovedFromAndroid(key));
-}
-
-void ArcBridgeServiceImpl::OnAppListRefreshed(
- mojo::Array<arc::AppInfoPtr> apps_ptr) {
- DCHECK(CalledOnValidThread());
- std::vector<arc::AppInfo> apps(apps_ptr.To<std::vector<arc::AppInfo>>());
- FOR_EACH_OBSERVER(AppObserver, app_observer_list(), OnAppListRefreshed(apps));
-}
-
-void ArcBridgeServiceImpl::OnAppIcon(const mojo::String& package,
- const mojo::String& activity,
- ScaleFactor scale_factor,
- mojo::Array<uint8_t> icon_png_data) {
- DCHECK(CalledOnValidThread());
- FOR_EACH_OBSERVER(
- AppObserver, app_observer_list(),
- OnAppIcon(package, activity, scale_factor, icon_png_data.storage()));
-}
-
-void ArcBridgeServiceImpl::OnAcquireDisplayWakeLock(DisplayWakeLockType type) {
- DCHECK(CalledOnValidThread());
- // TODO(ejcaruso): Implement.
- VLOG(1) << "OnAcquireDisplayWakeLock";
-}
-
-void ArcBridgeServiceImpl::OnReleaseDisplayWakeLock(DisplayWakeLockType type) {
- DCHECK(CalledOnValidThread());
- // TODO(ejcaruso): Implement.
- VLOG(1) << "OnReleaseDisplayWakeLock";
+ process_list_ptr_ = std::move(process_list_ptr);
+ FOR_EACH_OBSERVER(Observer, observer_list(), OnProcessListInstanceReady());
}
void ArcBridgeServiceImpl::OnArcAvailable(bool arc_available) {
@@ -237,7 +150,7 @@ void ArcBridgeServiceImpl::OnConnectionEstablished(
binding_.Bind(GetProxy(&host));
instance_ptr_->Init(std::move(host));
- SetState(State::CONNECTED);
+ SetState(State::READY);
}
void ArcBridgeServiceImpl::OnStopped() {

Powered by Google App Engine
This is Rietveld 408576698