| OLD | NEW |
| 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 #include "components/arc/arc_bridge_service_impl.h" | 5 #include "components/arc/arc_bridge_service_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
| 14 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
| 15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 16 #include "chromeos/chromeos_switches.h" | 16 #include "chromeos/chromeos_switches.h" |
| 17 #include "chromeos/dbus/dbus_method_call_status.h" | 17 #include "chromeos/dbus/dbus_method_call_status.h" |
| 18 #include "chromeos/dbus/dbus_thread_manager.h" | 18 #include "chromeos/dbus/dbus_thread_manager.h" |
| 19 #include "chromeos/dbus/session_manager_client.h" | 19 #include "chromeos/dbus/session_manager_client.h" |
| 20 #include "ipc/ipc_channel_handle.h" |
| 20 #include "mojo/public/cpp/bindings/array.h" | 21 #include "mojo/public/cpp/bindings/array.h" |
| 21 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 22 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
| 22 | 23 |
| 23 namespace mojo { | 24 namespace mojo { |
| 24 | 25 |
| 25 template <> | 26 template <> |
| 26 struct TypeConverter<arc::AppInfo, arc::AppInfoPtr> { | 27 struct TypeConverter<arc::AppInfo, arc::AppInfoPtr> { |
| 27 static arc::AppInfo Convert(const arc::AppInfoPtr& app_info_ptr) { | 28 static arc::AppInfo Convert(const arc::AppInfoPtr& app_info_ptr) { |
| 28 return *app_info_ptr; | 29 return *app_info_ptr; |
| 29 } | 30 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 bool ArcBridgeServiceImpl::RequestProcessList() { | 173 bool ArcBridgeServiceImpl::RequestProcessList() { |
| 173 DCHECK(CalledOnValidThread()); | 174 DCHECK(CalledOnValidThread()); |
| 174 if (state() != State::READY) { | 175 if (state() != State::READY) { |
| 175 LOG(ERROR) << "Called RequestProcessList when the service is not ready"; | 176 LOG(ERROR) << "Called RequestProcessList when the service is not ready"; |
| 176 return false; | 177 return false; |
| 177 } | 178 } |
| 178 instance_ptr_->RequestProcessList(); | 179 instance_ptr_->RequestProcessList(); |
| 179 return true; | 180 return true; |
| 180 } | 181 } |
| 181 | 182 |
| 183 void ArcBridgeServiceImpl::NotifyVideoAcceleratorChannelCreated( |
| 184 const IPC::ChannelHandle& handle) { |
| 185 DCHECK(CalledOnValidThread()); |
| 186 if (state() != State::READY) { |
| 187 LOG(ERROR) << "Called NotifyVideoAcceleratorChannelCreated when the " |
| 188 "service is not ready"; |
| 189 return; |
| 190 } |
| 191 // TODO revisit before commit: |
| 192 // can mojo create wrapper for invalid handle? |
| 193 MojoHandle wrapped_handle; |
| 194 MojoResult wrap_result = mojo::embedder::CreatePlatformHandleWrapper( |
| 195 mojo::embedder::ScopedPlatformHandle( |
| 196 mojo::embedder::PlatformHandle(handle.socket.fd)), |
| 197 &wrapped_handle); |
| 198 if (wrap_result != MOJO_RESULT_OK) { |
| 199 LOG(WARNING) << "Pipe failed to wrap handles. Closing: " << wrap_result; |
| 200 return; |
| 201 } |
| 202 instance_ptr_->NotifyVideoAcceleratorChannelCreated( |
| 203 mojo::ScopedHandle(mojo::Handle(wrapped_handle))); |
| 204 } |
| 205 |
| 182 void ArcBridgeServiceImpl::OnInstanceBootPhase(InstanceBootPhase phase) { | 206 void ArcBridgeServiceImpl::OnInstanceBootPhase(InstanceBootPhase phase) { |
| 183 DCHECK(CalledOnValidThread()); | 207 DCHECK(CalledOnValidThread()); |
| 184 // The state can be CONNECTED the first time this is called, and will then | 208 // The state can be CONNECTED the first time this is called, and will then |
| 185 // transition to READY after BRIDGE_READY has been passed. | 209 // transition to READY after BRIDGE_READY has been passed. |
| 186 if (state() != State::CONNECTED && state() != State::READY) { | 210 if (state() != State::CONNECTED && state() != State::READY) { |
| 187 VLOG(1) << "StopInstance() called while connecting"; | 211 VLOG(1) << "StopInstance() called while connecting"; |
| 188 return; | 212 return; |
| 189 } | 213 } |
| 190 if (phase == INSTANCE_BOOT_PHASE_BRIDGE_READY) { | 214 if (phase == INSTANCE_BOOT_PHASE_BRIDGE_READY) { |
| 191 SetState(State::READY); | 215 SetState(State::READY); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // TODO(ejcaruso): Implement. | 262 // TODO(ejcaruso): Implement. |
| 239 VLOG(1) << "OnAcquireDisplayWakeLock"; | 263 VLOG(1) << "OnAcquireDisplayWakeLock"; |
| 240 } | 264 } |
| 241 | 265 |
| 242 void ArcBridgeServiceImpl::OnReleaseDisplayWakeLock(DisplayWakeLockType type) { | 266 void ArcBridgeServiceImpl::OnReleaseDisplayWakeLock(DisplayWakeLockType type) { |
| 243 DCHECK(CalledOnValidThread()); | 267 DCHECK(CalledOnValidThread()); |
| 244 // TODO(ejcaruso): Implement. | 268 // TODO(ejcaruso): Implement. |
| 245 VLOG(1) << "OnReleaseDisplayWakeLock"; | 269 VLOG(1) << "OnReleaseDisplayWakeLock"; |
| 246 } | 270 } |
| 247 | 271 |
| 272 void ArcBridgeServiceImpl::OnRequestArcVideoAcceleratorChannel() { |
| 273 DCHECK(CalledOnValidThread()); |
| 274 if (!video_service()) { |
| 275 LOG(ERROR) << "Got OnRequestArcVideoAcceleratorChannel" |
| 276 " but video service is not registered"; |
| 277 return; |
| 278 } |
| 279 video_service()->OnRequestArcVideoAcceleratorChannel(); |
| 280 } |
| 281 |
| 248 void ArcBridgeServiceImpl::OnArcAvailable(bool arc_available) { | 282 void ArcBridgeServiceImpl::OnArcAvailable(bool arc_available) { |
| 249 DCHECK(CalledOnValidThread()); | 283 DCHECK(CalledOnValidThread()); |
| 250 if (available() == arc_available) | 284 if (available() == arc_available) |
| 251 return; | 285 return; |
| 252 SetAvailable(arc_available); | 286 SetAvailable(arc_available); |
| 253 PrerequisitesChanged(); | 287 PrerequisitesChanged(); |
| 254 } | 288 } |
| 255 | 289 |
| 256 void ArcBridgeServiceImpl::OnConnectionEstablished( | 290 void ArcBridgeServiceImpl::OnConnectionEstablished( |
| 257 ArcBridgeInstancePtr instance) { | 291 ArcBridgeInstancePtr instance) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 269 | 303 |
| 270 SetState(State::CONNECTED); | 304 SetState(State::CONNECTED); |
| 271 } | 305 } |
| 272 | 306 |
| 273 void ArcBridgeServiceImpl::OnStopped() { | 307 void ArcBridgeServiceImpl::OnStopped() { |
| 274 DCHECK(CalledOnValidThread()); | 308 DCHECK(CalledOnValidThread()); |
| 275 SetState(State::STOPPED); | 309 SetState(State::STOPPED); |
| 276 } | 310 } |
| 277 | 311 |
| 278 } // namespace arc | 312 } // namespace arc |
| OLD | NEW |