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

Side by Side Diff: cc/trees/remote_channel_impl.cc

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « cc/trees/remote_channel_impl.h ('k') | cc/trees/remote_channel_main.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 "cc/trees/remote_channel_impl.h" 5 #include "cc/trees/remote_channel_impl.h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/memory/ptr_util.h"
8 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
9 #include "cc/animation/animation_events.h" 10 #include "cc/animation/animation_events.h"
10 #include "cc/proto/compositor_message.pb.h" 11 #include "cc/proto/compositor_message.pb.h"
11 #include "cc/proto/compositor_message_to_impl.pb.h" 12 #include "cc/proto/compositor_message_to_impl.pb.h"
12 #include "cc/proto/compositor_message_to_main.pb.h" 13 #include "cc/proto/compositor_message_to_main.pb.h"
13 #include "cc/proto/gfx_conversions.h" 14 #include "cc/proto/gfx_conversions.h"
14 #include "cc/trees/layer_tree_host.h" 15 #include "cc/trees/layer_tree_host.h"
15 #include "cc/trees/layer_tree_settings.h" 16 #include "cc/trees/layer_tree_settings.h"
16 17
17 namespace cc { 18 namespace cc {
18 19
19 scoped_ptr<RemoteChannelImpl> RemoteChannelImpl::Create( 20 std::unique_ptr<RemoteChannelImpl> RemoteChannelImpl::Create(
20 LayerTreeHost* layer_tree_host, 21 LayerTreeHost* layer_tree_host,
21 RemoteProtoChannel* remote_proto_channel, 22 RemoteProtoChannel* remote_proto_channel,
22 TaskRunnerProvider* task_runner_provider) { 23 TaskRunnerProvider* task_runner_provider) {
23 return make_scoped_ptr(new RemoteChannelImpl( 24 return base::WrapUnique(new RemoteChannelImpl(
24 layer_tree_host, remote_proto_channel, task_runner_provider)); 25 layer_tree_host, remote_proto_channel, task_runner_provider));
25 } 26 }
26 27
27 RemoteChannelImpl::RemoteChannelImpl(LayerTreeHost* layer_tree_host, 28 RemoteChannelImpl::RemoteChannelImpl(LayerTreeHost* layer_tree_host,
28 RemoteProtoChannel* remote_proto_channel, 29 RemoteProtoChannel* remote_proto_channel,
29 TaskRunnerProvider* task_runner_provider) 30 TaskRunnerProvider* task_runner_provider)
30 : task_runner_provider_(task_runner_provider), 31 : task_runner_provider_(task_runner_provider),
31 main_thread_vars_unsafe_(this, layer_tree_host, remote_proto_channel), 32 main_thread_vars_unsafe_(this, layer_tree_host, remote_proto_channel),
32 compositor_thread_vars_unsafe_( 33 compositor_thread_vars_unsafe_(
33 main().remote_channel_weak_factory.GetWeakPtr()) { 34 main().remote_channel_weak_factory.GetWeakPtr()) {
34 DCHECK(task_runner_provider_->IsMainThread()); 35 DCHECK(task_runner_provider_->IsMainThread());
35 36
36 main().remote_proto_channel->SetProtoReceiver(this); 37 main().remote_proto_channel->SetProtoReceiver(this);
37 } 38 }
38 39
39 RemoteChannelImpl::~RemoteChannelImpl() { 40 RemoteChannelImpl::~RemoteChannelImpl() {
40 DCHECK(task_runner_provider_->IsMainThread()); 41 DCHECK(task_runner_provider_->IsMainThread());
41 DCHECK(!main().started); 42 DCHECK(!main().started);
42 43
43 main().remote_proto_channel->SetProtoReceiver(nullptr); 44 main().remote_proto_channel->SetProtoReceiver(nullptr);
44 } 45 }
45 46
46 scoped_ptr<ProxyImpl> RemoteChannelImpl::CreateProxyImpl( 47 std::unique_ptr<ProxyImpl> RemoteChannelImpl::CreateProxyImpl(
47 ChannelImpl* channel_impl, 48 ChannelImpl* channel_impl,
48 LayerTreeHost* layer_tree_host, 49 LayerTreeHost* layer_tree_host,
49 TaskRunnerProvider* task_runner_provider, 50 TaskRunnerProvider* task_runner_provider,
50 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 51 std::unique_ptr<BeginFrameSource> external_begin_frame_source) {
51 DCHECK(task_runner_provider_->IsImplThread()); 52 DCHECK(task_runner_provider_->IsImplThread());
52 DCHECK(!external_begin_frame_source); 53 DCHECK(!external_begin_frame_source);
53 return ProxyImpl::Create(channel_impl, layer_tree_host, task_runner_provider, 54 return ProxyImpl::Create(channel_impl, layer_tree_host, task_runner_provider,
54 std::move(external_begin_frame_source)); 55 std::move(external_begin_frame_source));
55 } 56 }
56 57
57 void RemoteChannelImpl::OnProtoReceived( 58 void RemoteChannelImpl::OnProtoReceived(
58 scoped_ptr<proto::CompositorMessage> proto) { 59 std::unique_ptr<proto::CompositorMessage> proto) {
59 DCHECK(task_runner_provider_->IsMainThread()); 60 DCHECK(task_runner_provider_->IsMainThread());
60 DCHECK(main().started); 61 DCHECK(main().started);
61 DCHECK(proto->has_to_impl()); 62 DCHECK(proto->has_to_impl());
62 63
63 // If we don't have an output surface, queue the message and defer processing 64 // If we don't have an output surface, queue the message and defer processing
64 // it till we initialize a new output surface. 65 // it till we initialize a new output surface.
65 if (main().waiting_for_output_surface_initialization) { 66 if (main().waiting_for_output_surface_initialization) {
66 VLOG(1) << "Queueing message proto since output surface was released."; 67 VLOG(1) << "Queueing message proto since output surface was released.";
67 main().pending_messages.push(proto->to_impl()); 68 main().pending_messages.push(proto->to_impl());
68 } else { 69 } else {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; 247 NOTREACHED() << "Should not be called on the remote client LayerTreeHost";
247 return false; 248 return false;
248 } 249 }
249 250
250 bool RemoteChannelImpl::BeginMainFrameRequested() const { 251 bool RemoteChannelImpl::BeginMainFrameRequested() const {
251 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; 252 NOTREACHED() << "Should not be called on the remote client LayerTreeHost";
252 return false; 253 return false;
253 } 254 }
254 255
255 void RemoteChannelImpl::Start( 256 void RemoteChannelImpl::Start(
256 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 257 std::unique_ptr<BeginFrameSource> external_begin_frame_source) {
257 DCHECK(task_runner_provider_->IsMainThread()); 258 DCHECK(task_runner_provider_->IsMainThread());
258 DCHECK(!main().started); 259 DCHECK(!main().started);
259 DCHECK(!external_begin_frame_source); 260 DCHECK(!external_begin_frame_source);
260 261
261 CompletionEvent completion; 262 CompletionEvent completion;
262 { 263 {
263 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); 264 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_);
264 ImplThreadTaskRunner()->PostTask( 265 ImplThreadTaskRunner()->PostTask(
265 FROM_HERE, base::Bind(&RemoteChannelImpl::InitializeImplOnImpl, 266 FROM_HERE, base::Bind(&RemoteChannelImpl::InitializeImplOnImpl,
266 base::Unretained(this), &completion, 267 base::Unretained(this), &completion,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 337
337 void RemoteChannelImpl::DidCompleteSwapBuffers() {} 338 void RemoteChannelImpl::DidCompleteSwapBuffers() {}
338 339
339 void RemoteChannelImpl::SetRendererCapabilitiesMainCopy( 340 void RemoteChannelImpl::SetRendererCapabilitiesMainCopy(
340 const RendererCapabilities& capabilities) {} 341 const RendererCapabilities& capabilities) {}
341 342
342 void RemoteChannelImpl::BeginMainFrameNotExpectedSoon() {} 343 void RemoteChannelImpl::BeginMainFrameNotExpectedSoon() {}
343 344
344 void RemoteChannelImpl::DidCommitAndDrawFrame() {} 345 void RemoteChannelImpl::DidCommitAndDrawFrame() {}
345 346
346 void RemoteChannelImpl::SetAnimationEvents(scoped_ptr<AnimationEvents> queue) {} 347 void RemoteChannelImpl::SetAnimationEvents(
348 std::unique_ptr<AnimationEvents> queue) {}
347 349
348 void RemoteChannelImpl::DidLoseOutputSurface() { 350 void RemoteChannelImpl::DidLoseOutputSurface() {
349 DCHECK(task_runner_provider_->IsImplThread()); 351 DCHECK(task_runner_provider_->IsImplThread());
350 352
351 MainThreadTaskRunner()->PostTask( 353 MainThreadTaskRunner()->PostTask(
352 FROM_HERE, base::Bind(&RemoteChannelImpl::DidLoseOutputSurfaceOnMain, 354 FROM_HERE, base::Bind(&RemoteChannelImpl::DidLoseOutputSurfaceOnMain,
353 impl().remote_channel_weak_ptr)); 355 impl().remote_channel_weak_ptr));
354 } 356 }
355 357
356 void RemoteChannelImpl::RequestNewOutputSurface() { 358 void RemoteChannelImpl::RequestNewOutputSurface() {
(...skipping 11 matching lines...) Expand all
368 370
369 MainThreadTaskRunner()->PostTask( 371 MainThreadTaskRunner()->PostTask(
370 FROM_HERE, 372 FROM_HERE,
371 base::Bind(&RemoteChannelImpl::DidInitializeOutputSurfaceOnMain, 373 base::Bind(&RemoteChannelImpl::DidInitializeOutputSurfaceOnMain,
372 impl().remote_channel_weak_ptr, success, capabilities)); 374 impl().remote_channel_weak_ptr, success, capabilities));
373 } 375 }
374 376
375 void RemoteChannelImpl::DidCompletePageScaleAnimation() {} 377 void RemoteChannelImpl::DidCompletePageScaleAnimation() {}
376 378
377 void RemoteChannelImpl::PostFrameTimingEventsOnMain( 379 void RemoteChannelImpl::PostFrameTimingEventsOnMain(
378 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 380 std::unique_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
379 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {} 381 std::unique_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
382 }
380 383
381 void RemoteChannelImpl::BeginMainFrame( 384 void RemoteChannelImpl::BeginMainFrame(
382 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { 385 std::unique_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) {
383 scoped_ptr<proto::CompositorMessage> proto; 386 std::unique_ptr<proto::CompositorMessage> proto;
384 proto.reset(new proto::CompositorMessage); 387 proto.reset(new proto::CompositorMessage);
385 proto::CompositorMessageToMain* to_main_proto = proto->mutable_to_main(); 388 proto::CompositorMessageToMain* to_main_proto = proto->mutable_to_main();
386 389
387 to_main_proto->set_message_type( 390 to_main_proto->set_message_type(
388 proto::CompositorMessageToMain::BEGIN_MAIN_FRAME); 391 proto::CompositorMessageToMain::BEGIN_MAIN_FRAME);
389 proto::BeginMainFrame* begin_main_frame_message = 392 proto::BeginMainFrame* begin_main_frame_message =
390 to_main_proto->mutable_begin_main_frame_message(); 393 to_main_proto->mutable_begin_main_frame_message();
391 begin_main_frame_state->ToProtobuf( 394 begin_main_frame_state->ToProtobuf(
392 begin_main_frame_message->mutable_begin_main_frame_state()); 395 begin_main_frame_message->mutable_begin_main_frame_state());
393 396
394 SendMessageProto(std::move(proto)); 397 SendMessageProto(std::move(proto));
395 } 398 }
396 399
397 void RemoteChannelImpl::SendMessageProto( 400 void RemoteChannelImpl::SendMessageProto(
398 scoped_ptr<proto::CompositorMessage> proto) { 401 std::unique_ptr<proto::CompositorMessage> proto) {
399 DCHECK(task_runner_provider_->IsImplThread()); 402 DCHECK(task_runner_provider_->IsImplThread());
400 403
401 MainThreadTaskRunner()->PostTask( 404 MainThreadTaskRunner()->PostTask(
402 FROM_HERE, 405 FROM_HERE,
403 base::Bind(&RemoteChannelImpl::SendMessageProtoOnMain, 406 base::Bind(&RemoteChannelImpl::SendMessageProtoOnMain,
404 impl().remote_channel_weak_ptr, base::Passed(&proto))); 407 impl().remote_channel_weak_ptr, base::Passed(&proto)));
405 } 408 }
406 409
407 void RemoteChannelImpl::DidLoseOutputSurfaceOnMain() { 410 void RemoteChannelImpl::DidLoseOutputSurfaceOnMain() {
408 DCHECK(task_runner_provider_->IsMainThread()); 411 DCHECK(task_runner_provider_->IsMainThread());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 main().pending_messages.pop(); 443 main().pending_messages.pop();
441 } 444 }
442 445
443 // The commit after a new output surface can early out, in which case we will 446 // The commit after a new output surface can early out, in which case we will
444 // never redraw. Schedule one just to be safe. 447 // never redraw. Schedule one just to be safe.
445 PostSetNeedsRedrawToImpl( 448 PostSetNeedsRedrawToImpl(
446 gfx::Rect(main().layer_tree_host->device_viewport_size())); 449 gfx::Rect(main().layer_tree_host->device_viewport_size()));
447 } 450 }
448 451
449 void RemoteChannelImpl::SendMessageProtoOnMain( 452 void RemoteChannelImpl::SendMessageProtoOnMain(
450 scoped_ptr<proto::CompositorMessage> proto) { 453 std::unique_ptr<proto::CompositorMessage> proto) {
451 DCHECK(task_runner_provider_->IsMainThread()); 454 DCHECK(task_runner_provider_->IsMainThread());
452 VLOG(1) << "Sending BeginMainFrame request to the engine."; 455 VLOG(1) << "Sending BeginMainFrame request to the engine.";
453 456
454 main().remote_proto_channel->SendCompositorProto(*proto); 457 main().remote_proto_channel->SendCompositorProto(*proto);
455 } 458 }
456 459
457 void RemoteChannelImpl::PostSetNeedsRedrawToImpl( 460 void RemoteChannelImpl::PostSetNeedsRedrawToImpl(
458 const gfx::Rect& damaged_rect) { 461 const gfx::Rect& damaged_rect) {
459 DCHECK(task_runner_provider_->IsMainThread()); 462 DCHECK(task_runner_provider_->IsMainThread());
460 463
461 ImplThreadTaskRunner()->PostTask( 464 ImplThreadTaskRunner()->PostTask(
462 FROM_HERE, base::Bind(&ProxyImpl::SetNeedsRedrawOnImpl, 465 FROM_HERE, base::Bind(&ProxyImpl::SetNeedsRedrawOnImpl,
463 proxy_impl_weak_ptr_, damaged_rect)); 466 proxy_impl_weak_ptr_, damaged_rect));
464 } 467 }
465 468
466 void RemoteChannelImpl::InitializeImplOnImpl(CompletionEvent* completion, 469 void RemoteChannelImpl::InitializeImplOnImpl(CompletionEvent* completion,
467 LayerTreeHost* layer_tree_host) { 470 LayerTreeHost* layer_tree_host) {
468 DCHECK(task_runner_provider_->IsMainThreadBlocked()); 471 DCHECK(task_runner_provider_->IsMainThreadBlocked());
469 DCHECK(task_runner_provider_->IsImplThread()); 472 DCHECK(task_runner_provider_->IsImplThread());
470 473
471 impl().proxy_impl = 474 impl().proxy_impl =
472 CreateProxyImpl(this, layer_tree_host, task_runner_provider_, nullptr); 475 CreateProxyImpl(this, layer_tree_host, task_runner_provider_, nullptr);
473 impl().proxy_impl_weak_factory = make_scoped_ptr( 476 impl().proxy_impl_weak_factory = base::WrapUnique(
474 new base::WeakPtrFactory<ProxyImpl>(impl().proxy_impl.get())); 477 new base::WeakPtrFactory<ProxyImpl>(impl().proxy_impl.get()));
475 proxy_impl_weak_ptr_ = impl().proxy_impl_weak_factory->GetWeakPtr(); 478 proxy_impl_weak_ptr_ = impl().proxy_impl_weak_factory->GetWeakPtr();
476 completion->Signal(); 479 completion->Signal();
477 } 480 }
478 481
479 void RemoteChannelImpl::ShutdownImplOnImpl(CompletionEvent* completion) { 482 void RemoteChannelImpl::ShutdownImplOnImpl(CompletionEvent* completion) {
480 DCHECK(task_runner_provider_->IsMainThreadBlocked()); 483 DCHECK(task_runner_provider_->IsMainThreadBlocked());
481 DCHECK(task_runner_provider_->IsImplThread()); 484 DCHECK(task_runner_provider_->IsImplThread());
482 485
483 // We must invalidate the proxy_impl weak ptrs and destroy the weak ptr 486 // We must invalidate the proxy_impl weak ptrs and destroy the weak ptr
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 537
535 RemoteChannelImpl::CompositorThreadOnly::CompositorThreadOnly( 538 RemoteChannelImpl::CompositorThreadOnly::CompositorThreadOnly(
536 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr) 539 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr)
537 : proxy_impl(nullptr), 540 : proxy_impl(nullptr),
538 proxy_impl_weak_factory(nullptr), 541 proxy_impl_weak_factory(nullptr),
539 remote_channel_weak_ptr(remote_channel_weak_ptr) {} 542 remote_channel_weak_ptr(remote_channel_weak_ptr) {}
540 543
541 RemoteChannelImpl::CompositorThreadOnly::~CompositorThreadOnly() {} 544 RemoteChannelImpl::CompositorThreadOnly::~CompositorThreadOnly() {}
542 545
543 } // namespace cc 546 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/remote_channel_impl.h ('k') | cc/trees/remote_channel_main.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698