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..4fed8a6ef48d8b2204aae9430ccab0a29221c955 100644 |
--- a/components/arc/arc_bridge_service_impl.cc |
+++ b/components/arc/arc_bridge_service_impl.cc |
@@ -17,6 +17,7 @@ |
#include "chromeos/dbus/dbus_method_call_status.h" |
#include "chromeos/dbus/dbus_thread_manager.h" |
#include "chromeos/dbus/session_manager_client.h" |
+#include "ipc/ipc_channel_handle.h" |
#include "mojo/public/cpp/bindings/array.h" |
#include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
@@ -160,6 +161,33 @@ bool ArcBridgeServiceImpl::RequestAppIcon(const std::string& package, |
return true; |
} |
+bool ArcBridgeServiceImpl::NotifyVideoAcceleratorChannelCreated( |
+ const IPC::ChannelHandle& handle) { |
Pawel Osciak
2015/12/16 10:17:58
Do we need to verify that handle is not IPC::Chann
kcwu
2015/12/16 14:05:32
Why? Both ArcBridgeServiceImpl and GpuArcVideoServ
Pawel Osciak
2015/12/23 06:24:01
Yes, but if creation failed we may get an empty ha
kcwu
2015/12/23 09:09:43
No, I want to let the remote caller handle the fai
|
+ DCHECK(CalledOnValidThread()); |
+ if (state() != State::READY) { |
+ LOG(ERROR) << "Called NotifyVideoAcceleratorChannelCreated when the " |
+ "service is not ready"; |
+ return false; |
+ } |
+ // TODO revisit before commit: |
+ // will the handle be closed exactly once? |
+ // can mojo create wrapper for invalid handle? |
+ MojoHandle wrapped_handle; |
+ MojoResult wrap_result = mojo::embedder::CreatePlatformHandleWrapper( |
+ mojo::embedder::ScopedPlatformHandle( |
+ mojo::embedder::PlatformHandle(handle.socket.fd)), |
+ &wrapped_handle); |
+ if (wrap_result != MOJO_RESULT_OK) { |
+ LOG(WARNING) << "Pipe failed to wrap handles. Closing: " << wrap_result; |
+ // Defer closing task to the ScopedFD. |
+ base::ScopedFD(handle.socket.fd); |
+ return false; |
Pawel Osciak
2015/12/16 10:17:58
Do we need to close also before returning from l.1
kcwu
2015/12/16 14:05:32
No need to close since it is already wrapped into
|
+ } |
+ instance_ptr_->NotifyVideoAcceleratorChannelCreated( |
+ mojo::ScopedHandle(mojo::Handle(wrapped_handle))); |
+ return true; |
+} |
+ |
void ArcBridgeServiceImpl::OnInstanceBootPhase(InstanceBootPhase phase) { |
DCHECK(CalledOnValidThread()); |
// The state can be CONNECTED the first time this is called, and will then |
@@ -215,6 +243,12 @@ void ArcBridgeServiceImpl::OnReleaseDisplayWakeLock(DisplayWakeLockType type) { |
VLOG(1) << "OnReleaseDisplayWakeLock"; |
} |
+void ArcBridgeServiceImpl::OnRequestArcVideoAcceleratorChannel() { |
+ DCHECK(CalledOnValidThread()); |
+ FOR_EACH_OBSERVER(VideoServiceObserver, video_service_observer_list(), |
+ OnRequestArcVideoAcceleratorChannel()); |
+} |
+ |
void ArcBridgeServiceImpl::OnArcAvailable(bool arc_available) { |
DCHECK(CalledOnValidThread()); |
if (available() == arc_available) |