Chromium Code Reviews| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 ScaleFactor scale_factor) { | 154 ScaleFactor scale_factor) { |
| 154 DCHECK(CalledOnValidThread()); | 155 DCHECK(CalledOnValidThread()); |
| 155 if (state() != State::READY) { | 156 if (state() != State::READY) { |
| 156 LOG(ERROR) << "Called RequestAppIcon when the service is not ready"; | 157 LOG(ERROR) << "Called RequestAppIcon when the service is not ready"; |
| 157 return false; | 158 return false; |
| 158 } | 159 } |
| 159 instance_ptr_->RequestAppIcon(package, activity, scale_factor); | 160 instance_ptr_->RequestAppIcon(package, activity, scale_factor); |
| 160 return true; | 161 return true; |
| 161 } | 162 } |
| 162 | 163 |
| 164 bool ArcBridgeServiceImpl::NotifyVideoAcceleratorChannelCreated( | |
| 165 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
| |
| 166 DCHECK(CalledOnValidThread()); | |
| 167 if (state() != State::READY) { | |
| 168 LOG(ERROR) << "Called NotifyVideoAcceleratorChannelCreated when the " | |
| 169 "service is not ready"; | |
| 170 return false; | |
| 171 } | |
| 172 // TODO revisit before commit: | |
| 173 // will the handle be closed exactly once? | |
| 174 // can mojo create wrapper for invalid handle? | |
| 175 MojoHandle wrapped_handle; | |
| 176 MojoResult wrap_result = mojo::embedder::CreatePlatformHandleWrapper( | |
| 177 mojo::embedder::ScopedPlatformHandle( | |
| 178 mojo::embedder::PlatformHandle(handle.socket.fd)), | |
| 179 &wrapped_handle); | |
| 180 if (wrap_result != MOJO_RESULT_OK) { | |
| 181 LOG(WARNING) << "Pipe failed to wrap handles. Closing: " << wrap_result; | |
| 182 // Defer closing task to the ScopedFD. | |
| 183 base::ScopedFD(handle.socket.fd); | |
| 184 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
| |
| 185 } | |
| 186 instance_ptr_->NotifyVideoAcceleratorChannelCreated( | |
| 187 mojo::ScopedHandle(mojo::Handle(wrapped_handle))); | |
| 188 return true; | |
| 189 } | |
| 190 | |
| 163 void ArcBridgeServiceImpl::OnInstanceBootPhase(InstanceBootPhase phase) { | 191 void ArcBridgeServiceImpl::OnInstanceBootPhase(InstanceBootPhase phase) { |
| 164 DCHECK(CalledOnValidThread()); | 192 DCHECK(CalledOnValidThread()); |
| 165 // The state can be CONNECTED the first time this is called, and will then | 193 // The state can be CONNECTED the first time this is called, and will then |
| 166 // transition to READY after BRIDGE_READY has been passed. | 194 // transition to READY after BRIDGE_READY has been passed. |
| 167 if (state() != State::CONNECTED && state() != State::READY) { | 195 if (state() != State::CONNECTED && state() != State::READY) { |
| 168 VLOG(1) << "StopInstance() called while connecting"; | 196 VLOG(1) << "StopInstance() called while connecting"; |
| 169 return; | 197 return; |
| 170 } | 198 } |
| 171 if (phase == INSTANCE_BOOT_PHASE_BRIDGE_READY) { | 199 if (phase == INSTANCE_BOOT_PHASE_BRIDGE_READY) { |
| 172 SetState(State::READY); | 200 SetState(State::READY); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 // TODO(ejcaruso): Implement. | 236 // TODO(ejcaruso): Implement. |
| 209 VLOG(1) << "OnAcquireDisplayWakeLock"; | 237 VLOG(1) << "OnAcquireDisplayWakeLock"; |
| 210 } | 238 } |
| 211 | 239 |
| 212 void ArcBridgeServiceImpl::OnReleaseDisplayWakeLock(DisplayWakeLockType type) { | 240 void ArcBridgeServiceImpl::OnReleaseDisplayWakeLock(DisplayWakeLockType type) { |
| 213 DCHECK(CalledOnValidThread()); | 241 DCHECK(CalledOnValidThread()); |
| 214 // TODO(ejcaruso): Implement. | 242 // TODO(ejcaruso): Implement. |
| 215 VLOG(1) << "OnReleaseDisplayWakeLock"; | 243 VLOG(1) << "OnReleaseDisplayWakeLock"; |
| 216 } | 244 } |
| 217 | 245 |
| 246 void ArcBridgeServiceImpl::OnRequestArcVideoAcceleratorChannel() { | |
| 247 DCHECK(CalledOnValidThread()); | |
| 248 FOR_EACH_OBSERVER(VideoServiceObserver, video_service_observer_list(), | |
| 249 OnRequestArcVideoAcceleratorChannel()); | |
| 250 } | |
| 251 | |
| 218 void ArcBridgeServiceImpl::OnArcAvailable(bool arc_available) { | 252 void ArcBridgeServiceImpl::OnArcAvailable(bool arc_available) { |
| 219 DCHECK(CalledOnValidThread()); | 253 DCHECK(CalledOnValidThread()); |
| 220 if (available() == arc_available) | 254 if (available() == arc_available) |
| 221 return; | 255 return; |
| 222 SetAvailable(arc_available); | 256 SetAvailable(arc_available); |
| 223 PrerequisitesChanged(); | 257 PrerequisitesChanged(); |
| 224 } | 258 } |
| 225 | 259 |
| 226 void ArcBridgeServiceImpl::OnConnectionEstablished( | 260 void ArcBridgeServiceImpl::OnConnectionEstablished( |
| 227 ArcBridgeInstancePtr instance) { | 261 ArcBridgeInstancePtr instance) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 239 | 273 |
| 240 SetState(State::CONNECTED); | 274 SetState(State::CONNECTED); |
| 241 } | 275 } |
| 242 | 276 |
| 243 void ArcBridgeServiceImpl::OnStopped() { | 277 void ArcBridgeServiceImpl::OnStopped() { |
| 244 DCHECK(CalledOnValidThread()); | 278 DCHECK(CalledOnValidThread()); |
| 245 SetState(State::STOPPED); | 279 SetState(State::STOPPED); |
| 246 } | 280 } |
| 247 | 281 |
| 248 } // namespace arc | 282 } // namespace arc |
| OLD | NEW |