+void RenderWidgetHostViewMac::AddPendingLatencyInfo(
+ const std::vector<ui::LatencyInfo>& latency_info) {
+ // If a screenshot is being taken when using CoreAnimation, send a few extra
+ // calls to setNeedsDisplay and wait for their resulting display calls,
+ // before reporting that the frame has reached the screen.
+ if (use_core_animation_) {
+ bool should_defer = false;
+ for (size_t i = 0; i < latency_info.size(); i++) {
+ if (latency_info[i].FindLatency(
+ ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT,
+ render_widget_host_->GetLatencyComponentId(),
+ NULL)) {
+ should_defer = true;
+ }
+ }
+ if (should_defer) {
+ // Multiple pending screenshot requests will work, but if every frame
+ // requests a screenshot, then the delay will never expire. Assert this
+ // here to avoid this.
+ CHECK_EQ(pending_latency_info_delay_, 0u);
+ // Wait a fixed number of frames (calls to CALayer::display) before
+ // claiming that the screenshot has reached the screen. This number
+ // comes from taking the first number where tests didn't fail (six),
+ // and doubling it.
+ const uint32 kScreenshotLatencyDelayInFrames = 12;
+ pending_latency_info_delay_ = kScreenshotLatencyDelayInFrames;
+ TickPendingLatencyInfoDelay();
+ }
+ }
+
+ for (size_t i = 0; i < latency_info.size(); i++) {
+ pending_latency_info_.push_back(latency_info[i]);
+ }
+}
+
+void RenderWidgetHostViewMac::SendPendingLatencyInfoToHost() {
+ if (pending_latency_info_delay_) {
+ pending_latency_info_delay_ -= 1;
+ return;
+ }
+ pending_latency_info_delay_weak_ptr_factory_.InvalidateWeakPtrs();
+
+ for (size_t i = 0; i < pending_latency_info_.size(); i++) {
+ pending_latency_info_[i].AddLatencyNumber(