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

Side by Side Diff: content/renderer/gpu/renderer_compositor_frame_sink.cc

Issue 2763633002: CHECK that the RendererCompositorFrameSink has been detached (Closed)
Patch Set: check-bound: . Created 3 years, 9 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 | « content/renderer/gpu/renderer_compositor_frame_sink.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/gpu/renderer_compositor_frame_sink.h" 5 #include "content/renderer/gpu/renderer_compositor_frame_sink.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 frame_swap_message_queue_(swap_frame_message_queue), 67 frame_swap_message_queue_(swap_frame_message_queue),
68 begin_frame_source_(std::move(begin_frame_source)), 68 begin_frame_source_(std::move(begin_frame_source)),
69 routing_id_(routing_id) { 69 routing_id_(routing_id) {
70 DCHECK(compositor_frame_sink_filter_); 70 DCHECK(compositor_frame_sink_filter_);
71 DCHECK(frame_swap_message_queue_); 71 DCHECK(frame_swap_message_queue_);
72 DCHECK(message_sender_); 72 DCHECK(message_sender_);
73 DCHECK(begin_frame_source_); 73 DCHECK(begin_frame_source_);
74 thread_checker_.DetachFromThread(); 74 thread_checker_.DetachFromThread();
75 } 75 }
76 76
77 RendererCompositorFrameSink::~RendererCompositorFrameSink() = default; 77 RendererCompositorFrameSink::~RendererCompositorFrameSink() {
78 // TODO(crbug.com/702764): If not detached then IPC messages would crash
79 // after this class is destroyed.
80 CHECK(!bound_);
81 }
78 82
79 bool RendererCompositorFrameSink::BindToClient( 83 bool RendererCompositorFrameSink::BindToClient(
80 cc::CompositorFrameSinkClient* client) { 84 cc::CompositorFrameSinkClient* client) {
81 DCHECK(thread_checker_.CalledOnValidThread()); 85 DCHECK(thread_checker_.CalledOnValidThread());
82 if (!cc::CompositorFrameSink::BindToClient(client)) 86 if (!cc::CompositorFrameSink::BindToClient(client))
83 return false; 87 return false;
84 88
85 DCHECK(begin_frame_source_); 89 DCHECK(begin_frame_source_);
86 client_->SetBeginFrameSource(begin_frame_source_.get()); 90 client_->SetBeginFrameSource(begin_frame_source_.get());
87 91
88 compositor_frame_sink_proxy_ = new RendererCompositorFrameSinkProxy(this); 92 compositor_frame_sink_proxy_ = new RendererCompositorFrameSinkProxy(this);
89 compositor_frame_sink_filter_handler_ = 93 compositor_frame_sink_filter_handler_ =
90 base::Bind(&RendererCompositorFrameSinkProxy::OnMessageReceived, 94 base::Bind(&RendererCompositorFrameSinkProxy::OnMessageReceived,
91 compositor_frame_sink_proxy_); 95 compositor_frame_sink_proxy_);
92 compositor_frame_sink_filter_->AddHandlerOnCompositorThread( 96 compositor_frame_sink_filter_->AddHandlerOnCompositorThread(
93 routing_id_, compositor_frame_sink_filter_handler_); 97 routing_id_, compositor_frame_sink_filter_handler_);
98 bound_ = true;
94 return true; 99 return true;
95 } 100 }
96 101
97 void RendererCompositorFrameSink::DetachFromClient() { 102 void RendererCompositorFrameSink::DetachFromClient() {
98 DCHECK(thread_checker_.CalledOnValidThread()); 103 DCHECK(thread_checker_.CalledOnValidThread());
99 client_->SetBeginFrameSource(nullptr); 104 client_->SetBeginFrameSource(nullptr);
100 // Destroy the begin frame source on the same thread it was bound on. 105 // Destroy the begin frame source on the same thread it was bound on.
101 // The CompositorFrameSink itself is destroyed on the main thread. 106 // The CompositorFrameSink itself is destroyed on the main thread.
102 begin_frame_source_ = nullptr; 107 begin_frame_source_ = nullptr;
103 compositor_frame_sink_proxy_->ClearCompositorFrameSink(); 108 compositor_frame_sink_proxy_->ClearCompositorFrameSink();
104 compositor_frame_sink_filter_->RemoveHandlerOnCompositorThread( 109 compositor_frame_sink_filter_->RemoveHandlerOnCompositorThread(
105 routing_id_, compositor_frame_sink_filter_handler_); 110 routing_id_, compositor_frame_sink_filter_handler_);
106 111
107 cc::CompositorFrameSink::DetachFromClient(); 112 cc::CompositorFrameSink::DetachFromClient();
113 bound_ = false;
108 } 114 }
109 115
110 void RendererCompositorFrameSink::SubmitCompositorFrame( 116 void RendererCompositorFrameSink::SubmitCompositorFrame(
111 cc::CompositorFrame frame) { 117 cc::CompositorFrame frame) {
112 { 118 {
113 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope> 119 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope>
114 send_message_scope = 120 send_message_scope =
115 frame_swap_message_queue_->AcquireSendMessageScope(); 121 frame_swap_message_queue_->AcquireSendMessageScope();
116 std::vector<std::unique_ptr<IPC::Message>> messages; 122 std::vector<std::unique_ptr<IPC::Message>> messages;
117 std::vector<IPC::Message> messages_to_deliver_with_frame; 123 std::vector<IPC::Message> messages_to_deliver_with_frame;
(...skipping 27 matching lines...) Expand all
145 client_->ReclaimResources(resources); 151 client_->ReclaimResources(resources);
146 if (is_swap_ack) 152 if (is_swap_ack)
147 client_->DidReceiveCompositorFrameAck(); 153 client_->DidReceiveCompositorFrameAck();
148 } 154 }
149 155
150 bool RendererCompositorFrameSink::Send(IPC::Message* message) { 156 bool RendererCompositorFrameSink::Send(IPC::Message* message) {
151 return message_sender_->Send(message); 157 return message_sender_->Send(message);
152 } 158 }
153 159
154 } // namespace content 160 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gpu/renderer_compositor_frame_sink.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698