| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/trees/remote_channel_impl.h" | |
| 6 | |
| 7 #include "base/bind_helpers.h" | |
| 8 #include "base/memory/ptr_util.h" | |
| 9 #include "base/single_thread_task_runner.h" | |
| 10 #include "cc/proto/compositor_message.pb.h" | |
| 11 #include "cc/proto/compositor_message_to_impl.pb.h" | |
| 12 #include "cc/proto/compositor_message_to_main.pb.h" | |
| 13 #include "cc/proto/gfx_conversions.h" | |
| 14 #include "cc/trees/layer_tree_host_in_process.h" | |
| 15 #include "cc/trees/layer_tree_settings.h" | |
| 16 #include "cc/trees/mutator_host.h" | |
| 17 | |
| 18 namespace cc { | |
| 19 | |
| 20 RemoteChannelImpl::RemoteChannelImpl(LayerTreeHostInProcess* layer_tree_host, | |
| 21 RemoteProtoChannel* remote_proto_channel, | |
| 22 TaskRunnerProvider* task_runner_provider) | |
| 23 : task_runner_provider_(task_runner_provider), | |
| 24 main_thread_vars_unsafe_(this, layer_tree_host, remote_proto_channel), | |
| 25 compositor_thread_vars_unsafe_( | |
| 26 main().remote_channel_weak_factory.GetWeakPtr()) { | |
| 27 DCHECK(task_runner_provider_->IsMainThread()); | |
| 28 | |
| 29 main().remote_proto_channel->SetProtoReceiver(this); | |
| 30 } | |
| 31 | |
| 32 RemoteChannelImpl::~RemoteChannelImpl() { | |
| 33 DCHECK(task_runner_provider_->IsMainThread()); | |
| 34 DCHECK(!main().started); | |
| 35 | |
| 36 main().remote_proto_channel->SetProtoReceiver(nullptr); | |
| 37 } | |
| 38 | |
| 39 std::unique_ptr<ProxyImpl> RemoteChannelImpl::CreateProxyImpl( | |
| 40 ChannelImpl* channel_impl, | |
| 41 LayerTreeHostInProcess* layer_tree_host, | |
| 42 TaskRunnerProvider* task_runner_provider) { | |
| 43 DCHECK(task_runner_provider_->IsImplThread()); | |
| 44 return base::MakeUnique<ProxyImpl>(channel_impl, layer_tree_host, | |
| 45 task_runner_provider); | |
| 46 } | |
| 47 | |
| 48 void RemoteChannelImpl::OnProtoReceived( | |
| 49 std::unique_ptr<proto::CompositorMessage> proto) { | |
| 50 DCHECK(task_runner_provider_->IsMainThread()); | |
| 51 DCHECK(main().started); | |
| 52 DCHECK(proto->has_to_impl()); | |
| 53 | |
| 54 // If we don't have an CompositorFrameSink, queue the message and defer | |
| 55 // processing it till we initialize a new CompositorFrameSink. | |
| 56 if (main().waiting_for_compositor_frame_sink_initialization) { | |
| 57 VLOG(1) << "Queueing message proto since CompositorFrameSink was released."; | |
| 58 main().pending_messages.push(proto->to_impl()); | |
| 59 } else { | |
| 60 HandleProto(proto->to_impl()); | |
| 61 } | |
| 62 } | |
| 63 | |
| 64 void RemoteChannelImpl::HandleProto( | |
| 65 const proto::CompositorMessageToImpl& proto) { | |
| 66 DCHECK(task_runner_provider_->IsMainThread()); | |
| 67 DCHECK(proto.has_message_type()); | |
| 68 DCHECK(!main().waiting_for_compositor_frame_sink_initialization); | |
| 69 | |
| 70 switch (proto.message_type()) { | |
| 71 case proto::CompositorMessageToImpl::UNKNOWN: | |
| 72 NOTIMPLEMENTED() << "Ignoring message of UNKNOWN type"; | |
| 73 break; | |
| 74 case proto::CompositorMessageToImpl::SET_NEEDS_COMMIT: | |
| 75 VLOG(1) << "Received commit request from the engine."; | |
| 76 ImplThreadTaskRunner()->PostTask( | |
| 77 FROM_HERE, | |
| 78 base::Bind(&ProxyImpl::SetNeedsCommitOnImpl, proxy_impl_weak_ptr_)); | |
| 79 break; | |
| 80 case proto::CompositorMessageToImpl::SET_DEFER_COMMITS: { | |
| 81 const proto::SetDeferCommits& defer_commits_message = | |
| 82 proto.defer_commits_message(); | |
| 83 bool defer_commits = defer_commits_message.defer_commits(); | |
| 84 VLOG(1) << "Received set defer commits to: " << defer_commits | |
| 85 << " from the engine."; | |
| 86 ImplThreadTaskRunner()->PostTask( | |
| 87 FROM_HERE, base::Bind(&ProxyImpl::SetDeferCommitsOnImpl, | |
| 88 proxy_impl_weak_ptr_, defer_commits)); | |
| 89 } break; | |
| 90 case proto::CompositorMessageToImpl::START_COMMIT: { | |
| 91 VLOG(1) << "Received commit proto from the engine."; | |
| 92 base::TimeTicks main_thread_start_time = base::TimeTicks::Now(); | |
| 93 const proto::StartCommit& start_commit_message = | |
| 94 proto.start_commit_message(); | |
| 95 | |
| 96 main().layer_tree_host->FromProtobufForCommit( | |
| 97 start_commit_message.layer_tree_host()); | |
| 98 | |
| 99 { | |
| 100 DebugScopedSetMainThreadBlocked main_thread_blocked( | |
| 101 task_runner_provider_); | |
| 102 CompletionEvent completion; | |
| 103 VLOG(1) << "Starting commit."; | |
| 104 ImplThreadTaskRunner()->PostTask( | |
| 105 FROM_HERE, | |
| 106 base::Bind(&ProxyImpl::NotifyReadyToCommitOnImpl, | |
| 107 proxy_impl_weak_ptr_, &completion, | |
| 108 main().layer_tree_host, main_thread_start_time, false)); | |
| 109 completion.Wait(); | |
| 110 } | |
| 111 } break; | |
| 112 case proto::CompositorMessageToImpl::BEGIN_MAIN_FRAME_ABORTED: { | |
| 113 base::TimeTicks main_thread_start_time = base::TimeTicks::Now(); | |
| 114 const proto::BeginMainFrameAborted& begin_main_frame_aborted_message = | |
| 115 proto.begin_main_frame_aborted_message(); | |
| 116 CommitEarlyOutReason reason = CommitEarlyOutReasonFromProtobuf( | |
| 117 begin_main_frame_aborted_message.reason()); | |
| 118 std::vector<std::unique_ptr<SwapPromise>> empty_swap_promises; | |
| 119 VLOG(1) << "Received BeginMainFrameAborted from the engine with reason: " | |
| 120 << CommitEarlyOutReasonToString(reason); | |
| 121 ImplThreadTaskRunner()->PostTask( | |
| 122 FROM_HERE, | |
| 123 base::Bind(&ProxyImpl::BeginMainFrameAbortedOnImpl, | |
| 124 proxy_impl_weak_ptr_, reason, main_thread_start_time, | |
| 125 base::Passed(&empty_swap_promises))); | |
| 126 } break; | |
| 127 case proto::CompositorMessageToImpl::SET_NEEDS_REDRAW: { | |
| 128 VLOG(1) << "Received redraw request from the engine."; | |
| 129 const proto::SetNeedsRedraw& set_needs_redraw_message = | |
| 130 proto.set_needs_redraw_message(); | |
| 131 gfx::Rect damaged_rect = | |
| 132 ProtoToRect(set_needs_redraw_message.damaged_rect()); | |
| 133 PostSetNeedsRedrawToImpl(damaged_rect); | |
| 134 } break; | |
| 135 } | |
| 136 } | |
| 137 | |
| 138 bool RemoteChannelImpl::IsStarted() const { | |
| 139 DCHECK(task_runner_provider_->IsMainThread()); | |
| 140 return main().started; | |
| 141 } | |
| 142 | |
| 143 bool RemoteChannelImpl::CommitToActiveTree() const { | |
| 144 return false; | |
| 145 } | |
| 146 | |
| 147 void RemoteChannelImpl::SetCompositorFrameSink( | |
| 148 CompositorFrameSink* compositor_frame_sink) { | |
| 149 DCHECK(task_runner_provider_->IsMainThread()); | |
| 150 | |
| 151 ImplThreadTaskRunner()->PostTask( | |
| 152 FROM_HERE, base::Bind(&ProxyImpl::InitializeCompositorFrameSinkOnImpl, | |
| 153 proxy_impl_weak_ptr_, compositor_frame_sink)); | |
| 154 } | |
| 155 | |
| 156 void RemoteChannelImpl::ReleaseCompositorFrameSink() { | |
| 157 DCHECK(task_runner_provider_->IsMainThread()); | |
| 158 DCHECK(!main().waiting_for_compositor_frame_sink_initialization); | |
| 159 VLOG(1) << "Releasing CompositorFrameSink"; | |
| 160 | |
| 161 { | |
| 162 CompletionEvent completion; | |
| 163 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | |
| 164 ImplThreadTaskRunner()->PostTask( | |
| 165 FROM_HERE, base::Bind(&ProxyImpl::ReleaseCompositorFrameSinkOnImpl, | |
| 166 proxy_impl_weak_ptr_, &completion)); | |
| 167 completion.Wait(); | |
| 168 } | |
| 169 | |
| 170 main().waiting_for_compositor_frame_sink_initialization = true; | |
| 171 } | |
| 172 | |
| 173 void RemoteChannelImpl::SetVisible(bool visible) { | |
| 174 DCHECK(task_runner_provider_->IsMainThread()); | |
| 175 VLOG(1) << "Setting visibility to: " << visible; | |
| 176 | |
| 177 ImplThreadTaskRunner()->PostTask( | |
| 178 FROM_HERE, | |
| 179 base::Bind(&ProxyImpl::SetVisibleOnImpl, proxy_impl_weak_ptr_, visible)); | |
| 180 } | |
| 181 | |
| 182 void RemoteChannelImpl::SetNeedsAnimate() { | |
| 183 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | |
| 184 } | |
| 185 | |
| 186 void RemoteChannelImpl::SetNeedsUpdateLayers() { | |
| 187 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | |
| 188 } | |
| 189 | |
| 190 void RemoteChannelImpl::SetNeedsCommit() { | |
| 191 // Ideally commits should be requested only on the server. But we have to | |
| 192 // allow this call since the LayerTreeHostInProcesswill currently ask for a | |
| 193 // commit in 2 cases: | |
| 194 // 1) When it is being initialized from a protobuf for a commit. | |
| 195 // 2) When it loses the CompositorFrameSink. | |
| 196 NOTIMPLEMENTED() << "Commits should not be requested on the client"; | |
| 197 } | |
| 198 | |
| 199 void RemoteChannelImpl::SetNeedsRedraw(const gfx::Rect& damage_rect) { | |
| 200 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | |
| 201 } | |
| 202 | |
| 203 void RemoteChannelImpl::SetNextCommitWaitsForActivation() { | |
| 204 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | |
| 205 } | |
| 206 | |
| 207 void RemoteChannelImpl::NotifyInputThrottledUntilCommit() { | |
| 208 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | |
| 209 } | |
| 210 | |
| 211 void RemoteChannelImpl::SetDeferCommits(bool defer_commits) { | |
| 212 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | |
| 213 } | |
| 214 | |
| 215 void RemoteChannelImpl::MainThreadHasStoppedFlinging() { | |
| 216 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | |
| 217 } | |
| 218 | |
| 219 bool RemoteChannelImpl::CommitRequested() const { | |
| 220 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | |
| 221 return false; | |
| 222 } | |
| 223 | |
| 224 bool RemoteChannelImpl::BeginMainFrameRequested() const { | |
| 225 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | |
| 226 return false; | |
| 227 } | |
| 228 | |
| 229 void RemoteChannelImpl::Start() { | |
| 230 DCHECK(task_runner_provider_->IsMainThread()); | |
| 231 DCHECK(!main().started); | |
| 232 | |
| 233 CompletionEvent completion; | |
| 234 { | |
| 235 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | |
| 236 ImplThreadTaskRunner()->PostTask( | |
| 237 FROM_HERE, base::Bind(&RemoteChannelImpl::InitializeImplOnImpl, | |
| 238 base::Unretained(this), &completion, | |
| 239 main().layer_tree_host)); | |
| 240 completion.Wait(); | |
| 241 } | |
| 242 main().started = true; | |
| 243 } | |
| 244 | |
| 245 void RemoteChannelImpl::Stop() { | |
| 246 DCHECK(task_runner_provider_->IsMainThread()); | |
| 247 DCHECK(main().started); | |
| 248 | |
| 249 { | |
| 250 CompletionEvent completion; | |
| 251 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | |
| 252 ImplThreadTaskRunner()->PostTask( | |
| 253 FROM_HERE, base::Bind(&ProxyImpl::FinishGLOnImpl, proxy_impl_weak_ptr_, | |
| 254 &completion)); | |
| 255 completion.Wait(); | |
| 256 } | |
| 257 { | |
| 258 CompletionEvent completion; | |
| 259 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | |
| 260 ImplThreadTaskRunner()->PostTask( | |
| 261 FROM_HERE, base::Bind(&RemoteChannelImpl::ShutdownImplOnImpl, | |
| 262 base::Unretained(this), &completion)); | |
| 263 completion.Wait(); | |
| 264 } | |
| 265 | |
| 266 main().started = false; | |
| 267 main().remote_channel_weak_factory.InvalidateWeakPtrs(); | |
| 268 } | |
| 269 | |
| 270 void RemoteChannelImpl::SetMutator(std::unique_ptr<LayerTreeMutator> mutator) { | |
| 271 // TODO(vollick): add support for compositor worker. | |
| 272 } | |
| 273 | |
| 274 bool RemoteChannelImpl::SupportsImplScrolling() const { | |
| 275 return true; | |
| 276 } | |
| 277 | |
| 278 void RemoteChannelImpl::UpdateBrowserControlsState( | |
| 279 BrowserControlsState constraints, | |
| 280 BrowserControlsState current, | |
| 281 bool animate) { | |
| 282 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | |
| 283 } | |
| 284 | |
| 285 bool RemoteChannelImpl::MainFrameWillHappenForTesting() { | |
| 286 DCHECK(task_runner_provider_->IsMainThread()); | |
| 287 bool main_frame_will_happen; | |
| 288 { | |
| 289 CompletionEvent completion; | |
| 290 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | |
| 291 ImplThreadTaskRunner()->PostTask( | |
| 292 FROM_HERE, | |
| 293 base::Bind(&ProxyImpl::MainFrameWillHappenOnImplForTesting, | |
| 294 proxy_impl_weak_ptr_, &completion, &main_frame_will_happen)); | |
| 295 completion.Wait(); | |
| 296 } | |
| 297 return main_frame_will_happen; | |
| 298 } | |
| 299 | |
| 300 void RemoteChannelImpl::DidReceiveCompositorFrameAck() { | |
| 301 DCHECK(task_runner_provider_->IsImplThread()); | |
| 302 MainThreadTaskRunner()->PostTask( | |
| 303 FROM_HERE, | |
| 304 base::Bind(&RemoteChannelImpl::DidReceiveCompositorFrameAckOnMain, | |
| 305 impl().remote_channel_weak_ptr)); | |
| 306 } | |
| 307 | |
| 308 void RemoteChannelImpl::BeginMainFrameNotExpectedSoon() {} | |
| 309 | |
| 310 void RemoteChannelImpl::DidCommitAndDrawFrame() { | |
| 311 DCHECK(task_runner_provider_->IsImplThread()); | |
| 312 MainThreadTaskRunner()->PostTask( | |
| 313 FROM_HERE, base::Bind(&RemoteChannelImpl::DidCommitAndDrawFrameOnMain, | |
| 314 impl().remote_channel_weak_ptr)); | |
| 315 } | |
| 316 | |
| 317 void RemoteChannelImpl::SetAnimationEvents( | |
| 318 std::unique_ptr<MutatorEvents> queue) {} | |
| 319 | |
| 320 void RemoteChannelImpl::DidLoseCompositorFrameSink() { | |
| 321 DCHECK(task_runner_provider_->IsImplThread()); | |
| 322 | |
| 323 MainThreadTaskRunner()->PostTask( | |
| 324 FROM_HERE, | |
| 325 base::Bind(&RemoteChannelImpl::DidLoseCompositorFrameSinkOnMain, | |
| 326 impl().remote_channel_weak_ptr)); | |
| 327 } | |
| 328 | |
| 329 void RemoteChannelImpl::RequestNewCompositorFrameSink() { | |
| 330 DCHECK(task_runner_provider_->IsImplThread()); | |
| 331 | |
| 332 MainThreadTaskRunner()->PostTask( | |
| 333 FROM_HERE, | |
| 334 base::Bind(&RemoteChannelImpl::RequestNewCompositorFrameSinkOnMain, | |
| 335 impl().remote_channel_weak_ptr)); | |
| 336 } | |
| 337 | |
| 338 void RemoteChannelImpl::DidInitializeCompositorFrameSink(bool success) { | |
| 339 DCHECK(task_runner_provider_->IsImplThread()); | |
| 340 | |
| 341 MainThreadTaskRunner()->PostTask( | |
| 342 FROM_HERE, | |
| 343 base::Bind(&RemoteChannelImpl::DidInitializeCompositorFrameSinkOnMain, | |
| 344 impl().remote_channel_weak_ptr, success)); | |
| 345 } | |
| 346 | |
| 347 void RemoteChannelImpl::DidCompletePageScaleAnimation() {} | |
| 348 | |
| 349 void RemoteChannelImpl::BeginMainFrame( | |
| 350 std::unique_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { | |
| 351 std::unique_ptr<proto::CompositorMessage> proto; | |
| 352 proto.reset(new proto::CompositorMessage); | |
| 353 proto::CompositorMessageToMain* to_main_proto = proto->mutable_to_main(); | |
| 354 | |
| 355 to_main_proto->set_message_type( | |
| 356 proto::CompositorMessageToMain::BEGIN_MAIN_FRAME); | |
| 357 proto::BeginMainFrame* begin_main_frame_message = | |
| 358 to_main_proto->mutable_begin_main_frame_message(); | |
| 359 begin_main_frame_state->ToProtobuf( | |
| 360 begin_main_frame_message->mutable_begin_main_frame_state()); | |
| 361 | |
| 362 SendMessageProto(std::move(proto)); | |
| 363 } | |
| 364 | |
| 365 void RemoteChannelImpl::SendMessageProto( | |
| 366 std::unique_ptr<proto::CompositorMessage> proto) { | |
| 367 DCHECK(task_runner_provider_->IsImplThread()); | |
| 368 | |
| 369 MainThreadTaskRunner()->PostTask( | |
| 370 FROM_HERE, | |
| 371 base::Bind(&RemoteChannelImpl::SendMessageProtoOnMain, | |
| 372 impl().remote_channel_weak_ptr, base::Passed(&proto))); | |
| 373 } | |
| 374 | |
| 375 void RemoteChannelImpl::DidReceiveCompositorFrameAckOnMain() { | |
| 376 DCHECK(task_runner_provider_->IsMainThread()); | |
| 377 main().layer_tree_host->DidReceiveCompositorFrameAck(); | |
| 378 } | |
| 379 | |
| 380 void RemoteChannelImpl::DidCommitAndDrawFrameOnMain() { | |
| 381 DCHECK(task_runner_provider_->IsMainThread()); | |
| 382 main().layer_tree_host->DidCommitAndDrawFrame(); | |
| 383 } | |
| 384 | |
| 385 void RemoteChannelImpl::DidLoseCompositorFrameSinkOnMain() { | |
| 386 DCHECK(task_runner_provider_->IsMainThread()); | |
| 387 | |
| 388 main().layer_tree_host->DidLoseCompositorFrameSink(); | |
| 389 } | |
| 390 | |
| 391 void RemoteChannelImpl::RequestNewCompositorFrameSinkOnMain() { | |
| 392 DCHECK(task_runner_provider_->IsMainThread()); | |
| 393 | |
| 394 main().layer_tree_host->RequestNewCompositorFrameSink(); | |
| 395 } | |
| 396 | |
| 397 void RemoteChannelImpl::DidInitializeCompositorFrameSinkOnMain(bool success) { | |
| 398 DCHECK(task_runner_provider_->IsMainThread()); | |
| 399 | |
| 400 if (!success) { | |
| 401 main().layer_tree_host->DidFailToInitializeCompositorFrameSink(); | |
| 402 return; | |
| 403 } | |
| 404 | |
| 405 VLOG(1) << "CompositorFrameSink initialized successfully"; | |
| 406 main().layer_tree_host->DidInitializeCompositorFrameSink(); | |
| 407 | |
| 408 // If we were waiting for CompositorFrameSink initialization, we might have | |
| 409 // queued some messages. Relay them now that a new CompositorFrameSink has | |
| 410 // been initialized. | |
| 411 main().waiting_for_compositor_frame_sink_initialization = false; | |
| 412 while (!main().pending_messages.empty()) { | |
| 413 VLOG(1) << "Handling queued message"; | |
| 414 HandleProto(main().pending_messages.front()); | |
| 415 main().pending_messages.pop(); | |
| 416 } | |
| 417 | |
| 418 // The commit after a new CompositorFrameSink can early out, in which case we | |
| 419 // will never redraw. Schedule one just to be safe. | |
| 420 PostSetNeedsRedrawToImpl(gfx::Rect( | |
| 421 main().layer_tree_host->GetLayerTree()->device_viewport_size())); | |
| 422 } | |
| 423 | |
| 424 void RemoteChannelImpl::SendMessageProtoOnMain( | |
| 425 std::unique_ptr<proto::CompositorMessage> proto) { | |
| 426 DCHECK(task_runner_provider_->IsMainThread()); | |
| 427 VLOG(1) << "Sending BeginMainFrame request to the engine."; | |
| 428 | |
| 429 main().remote_proto_channel->SendCompositorProto(*proto); | |
| 430 } | |
| 431 | |
| 432 void RemoteChannelImpl::PostSetNeedsRedrawToImpl( | |
| 433 const gfx::Rect& damaged_rect) { | |
| 434 DCHECK(task_runner_provider_->IsMainThread()); | |
| 435 | |
| 436 ImplThreadTaskRunner()->PostTask( | |
| 437 FROM_HERE, base::Bind(&ProxyImpl::SetNeedsRedrawOnImpl, | |
| 438 proxy_impl_weak_ptr_, damaged_rect)); | |
| 439 } | |
| 440 | |
| 441 void RemoteChannelImpl::InitializeImplOnImpl( | |
| 442 CompletionEvent* completion, | |
| 443 LayerTreeHostInProcess* layer_tree_host) { | |
| 444 DCHECK(task_runner_provider_->IsMainThreadBlocked()); | |
| 445 DCHECK(task_runner_provider_->IsImplThread()); | |
| 446 | |
| 447 impl().proxy_impl = | |
| 448 CreateProxyImpl(this, layer_tree_host, task_runner_provider_); | |
| 449 impl().proxy_impl_weak_factory = | |
| 450 base::MakeUnique<base::WeakPtrFactory<ProxyImpl>>( | |
| 451 impl().proxy_impl.get()); | |
| 452 proxy_impl_weak_ptr_ = impl().proxy_impl_weak_factory->GetWeakPtr(); | |
| 453 completion->Signal(); | |
| 454 } | |
| 455 | |
| 456 void RemoteChannelImpl::ShutdownImplOnImpl(CompletionEvent* completion) { | |
| 457 DCHECK(task_runner_provider_->IsMainThreadBlocked()); | |
| 458 DCHECK(task_runner_provider_->IsImplThread()); | |
| 459 | |
| 460 // We must invalidate the proxy_impl weak ptrs and destroy the weak ptr | |
| 461 // factory before destroying proxy_impl. | |
| 462 impl().proxy_impl_weak_factory->InvalidateWeakPtrs(); | |
| 463 impl().proxy_impl_weak_factory.reset(); | |
| 464 | |
| 465 impl().proxy_impl.reset(); | |
| 466 completion->Signal(); | |
| 467 } | |
| 468 | |
| 469 RemoteChannelImpl::MainThreadOnly& RemoteChannelImpl::main() { | |
| 470 DCHECK(task_runner_provider_->IsMainThread()); | |
| 471 return main_thread_vars_unsafe_; | |
| 472 } | |
| 473 | |
| 474 const RemoteChannelImpl::MainThreadOnly& RemoteChannelImpl::main() const { | |
| 475 DCHECK(task_runner_provider_->IsMainThread()); | |
| 476 return main_thread_vars_unsafe_; | |
| 477 } | |
| 478 | |
| 479 RemoteChannelImpl::CompositorThreadOnly& RemoteChannelImpl::impl() { | |
| 480 DCHECK(task_runner_provider_->IsImplThread()); | |
| 481 return compositor_thread_vars_unsafe_; | |
| 482 } | |
| 483 | |
| 484 const RemoteChannelImpl::CompositorThreadOnly& RemoteChannelImpl::impl() const { | |
| 485 DCHECK(task_runner_provider_->IsImplThread()); | |
| 486 return compositor_thread_vars_unsafe_; | |
| 487 } | |
| 488 | |
| 489 base::SingleThreadTaskRunner* RemoteChannelImpl::MainThreadTaskRunner() const { | |
| 490 return task_runner_provider_->MainThreadTaskRunner(); | |
| 491 } | |
| 492 | |
| 493 base::SingleThreadTaskRunner* RemoteChannelImpl::ImplThreadTaskRunner() const { | |
| 494 return task_runner_provider_->ImplThreadTaskRunner(); | |
| 495 } | |
| 496 | |
| 497 RemoteChannelImpl::MainThreadOnly::MainThreadOnly( | |
| 498 RemoteChannelImpl* remote_channel_impl, | |
| 499 LayerTreeHostInProcess* layer_tree_host, | |
| 500 RemoteProtoChannel* remote_proto_channel) | |
| 501 : layer_tree_host(layer_tree_host), | |
| 502 remote_proto_channel(remote_proto_channel), | |
| 503 started(false), | |
| 504 waiting_for_compositor_frame_sink_initialization(false), | |
| 505 remote_channel_weak_factory(remote_channel_impl) { | |
| 506 DCHECK(layer_tree_host); | |
| 507 DCHECK(remote_proto_channel); | |
| 508 } | |
| 509 | |
| 510 RemoteChannelImpl::MainThreadOnly::~MainThreadOnly() {} | |
| 511 | |
| 512 RemoteChannelImpl::CompositorThreadOnly::CompositorThreadOnly( | |
| 513 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr) | |
| 514 : proxy_impl(nullptr), | |
| 515 proxy_impl_weak_factory(nullptr), | |
| 516 remote_channel_weak_ptr(remote_channel_weak_ptr) {} | |
| 517 | |
| 518 RemoteChannelImpl::CompositorThreadOnly::~CompositorThreadOnly() {} | |
| 519 | |
| 520 } // namespace cc | |
| OLD | NEW |