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

Side by Side Diff: cc/scheduler/begin_frame_source.cc

Issue 2706493002: Check for BeginFrame time/seqnum continuity in ExternalBFS::OnBF. (Closed)
Patch Set: Use const ref. Created 3 years, 10 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 | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/scheduler/begin_frame_source.h" 5 #include "cc/scheduler/begin_frame_source.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 DCHECK(observers_.find(obs) == observers_.end()); 254 DCHECK(observers_.find(obs) == observers_.end());
255 255
256 bool observers_was_empty = observers_.empty(); 256 bool observers_was_empty = observers_.empty();
257 observers_.insert(obs); 257 observers_.insert(obs);
258 obs->OnBeginFrameSourcePausedChanged(paused_); 258 obs->OnBeginFrameSourcePausedChanged(paused_);
259 if (observers_was_empty) 259 if (observers_was_empty)
260 client_->OnNeedsBeginFrames(true); 260 client_->OnNeedsBeginFrames(true);
261 261
262 // Send a MISSED begin frame if necessary. 262 // Send a MISSED begin frame if necessary.
263 if (missed_begin_frame_args_.IsValid()) { 263 if (missed_begin_frame_args_.IsValid()) {
264 BeginFrameArgs last_args = obs->LastUsedBeginFrameArgs(); 264 const BeginFrameArgs& last_args = obs->LastUsedBeginFrameArgs();
265 if (!last_args.IsValid() || 265 if (!last_args.IsValid() ||
266 (missed_begin_frame_args_.frame_time > last_args.frame_time)) { 266 (missed_begin_frame_args_.frame_time > last_args.frame_time)) {
267 DCHECK((missed_begin_frame_args_.source_id != last_args.source_id) || 267 DCHECK((missed_begin_frame_args_.source_id != last_args.source_id) ||
268 (missed_begin_frame_args_.sequence_number > 268 (missed_begin_frame_args_.sequence_number >
269 last_args.sequence_number)) 269 last_args.sequence_number))
270 << "current " << missed_begin_frame_args_.AsValue()->ToString() 270 << "current " << missed_begin_frame_args_.AsValue()->ToString()
271 << ", last " << last_args.AsValue()->ToString(); 271 << ", last " << last_args.AsValue()->ToString();
272 obs->OnBeginFrame(missed_begin_frame_args_); 272 obs->OnBeginFrame(missed_begin_frame_args_);
273 } 273 }
274 } 274 }
(...skipping 20 matching lines...) Expand all
295 paused_ = paused; 295 paused_ = paused;
296 std::unordered_set<BeginFrameObserver*> observers(observers_); 296 std::unordered_set<BeginFrameObserver*> observers(observers_);
297 for (auto* obs : observers) 297 for (auto* obs : observers)
298 obs->OnBeginFrameSourcePausedChanged(paused_); 298 obs->OnBeginFrameSourcePausedChanged(paused_);
299 } 299 }
300 300
301 void ExternalBeginFrameSource::OnBeginFrame(const BeginFrameArgs& args) { 301 void ExternalBeginFrameSource::OnBeginFrame(const BeginFrameArgs& args) {
302 missed_begin_frame_args_ = args; 302 missed_begin_frame_args_ = args;
303 missed_begin_frame_args_.type = BeginFrameArgs::MISSED; 303 missed_begin_frame_args_.type = BeginFrameArgs::MISSED;
304 std::unordered_set<BeginFrameObserver*> observers(observers_); 304 std::unordered_set<BeginFrameObserver*> observers(observers_);
305 for (auto* obs : observers) 305 for (auto* obs : observers) {
306 obs->OnBeginFrame(args); 306 // It is possible that the source in which |args| originate changes, or that
307 // our hookup to this source changes, so we have to check for continuity.
308 // See also https://crbug.com/690127 for what may happen without this check.
309 const BeginFrameArgs& last_args = obs->LastUsedBeginFrameArgs();
310 if (!last_args.IsValid() || (args.frame_time > last_args.frame_time)) {
311 DCHECK((args.source_id != last_args.source_id) ||
312 (args.sequence_number > last_args.sequence_number))
313 << "current " << args.AsValue()->ToString() << ", last "
314 << last_args.AsValue()->ToString();
315 obs->OnBeginFrame(args);
316 }
317 }
307 } 318 }
308 319
309 } // namespace cc 320 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698