Revert 237857 "Revert 237848 "Use LatencyInfoSwapPromise to trac..."

Guess win8_aura is just really flaky...

> Revert 237848 "Use LatencyInfoSwapPromise to track LatencyInfo t..."
> 
> Speculative revert to see if this broke views_unittests, event_unittests, and
> aura_unittests to be crashed or hung. Example:
> 
> E:\b\build\slave\Win8_Aura\build\src\out\Debug\events_unittests.exe --brave-new-test-launcher --test-launcher-bot-mode --gtest_print_time --gtest_output=xml:E:\b\build\slave\Win8_Aura\build\gtest-results\events_unittests\events_unittests.xml
> IMPORTANT DEBUGGING NOTE: batches of tests are run inside their
> own process. For debugging a test inside a debugger, use the
> --gtest_filter=<your_test_name> flag along with
> --single-process-tests.
> Enabling defaults optimized for continuous integration bots.
> Using sharding settings from environment. This is shard 0/1
> Using 8 parallel jobs.
> [1128/165136:ERROR:launch_win.cc(166)] : Access is denied.
> [1128/165136:ERROR:launch_win.cc(166)] : Access is denied.
> Failed to get out-of-band test success data, dumping full stdio below:
> 
> [1/29] EventDispatcherTest.EventDispatchOrder (UNKNOWN)
> [2/29] EventDispatcherTest.EventDispatchPhase (UNKNOWN)
> [3/29] EventDispatcherTest.EventDispatcherDestroyedDuringDispatch (UNKNOWN)
> [4/29] EventDispatcherTest.EventDispatcherInvalidateTarget (UNKNOWN)
> [5/29] EventDispatcherTest.EventHandlerDestroyedDuringDispatch (UNKNOWN)
> [6/29] EventDispatcherTest.EventHandlerAndDispatcherDestroyedDuringDispatch (UNKNOWN)
> [7/29] LatencyInfoTest.AddTwoSeparateEvent (UNKNOWN)
> [8/29] LatencyInfoTest.AddTwoSameEvent (UNKNOWN)
> [9/29] LatencyInfoTest.MergeTwoSeparateEvent (UNKNOWN)
> [10/29] LatencyInfoTest.MergeTwoSameEvent (UNKNOWN)
> Too many badly broken tests (10), exiting now.
> [1128/165136:ERROR:launch_win.cc(166)] : Access is denied.
> Error:  no element found: line 1, column 0
> No data was available to update the JSON results
> exit code (as seen by runtest.py): 1
> @@@STEP_FAILURE@@@
> @@@STEP_TEXT@events_unittests@@@
> @@@STEP_TEXT@crashed or hung@@@
> 
> > Use LatencyInfoSwapPromise to track LatencyInfo through compositor
> > 
> > Originally we cache LatencyInfo directly in compositor. Now that
> > with the support of SwapPromise, we can use LatencyInfoSwapPromise
> > to track the LatencyInfo.
> > 
> > BUG=246034
> > TEST=Input LatencyInfo are still correctly passed to output surface
> >      through LatencyInfoSwapPromise.
> > 
> > Review URL: https://codereview.chromium.org/81533002
> 
> [email protected]
> 
> Review URL: https://codereview.chromium.org/96073002

[email protected]

Review URL: https://codereview.chromium.org/96363002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237887 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index b5ad77f..3ab5385e 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -15,6 +15,7 @@
 #include "base/strings/stringprintf.h"
 #include "cc/animation/scrollbar_animation_controller.h"
 #include "cc/animation/timing_function.h"
+#include "cc/base/latency_info_swap_promise.h"
 #include "cc/base/math_util.h"
 #include "cc/base/util.h"
 #include "cc/debug/benchmark_instrumentation.h"
@@ -474,7 +475,9 @@
 
 void LayerTreeHostImpl::SetLatencyInfoForInputEvent(
     const ui::LatencyInfo& latency_info) {
-  active_tree()->SetLatencyInfo(latency_info);
+  scoped_ptr<SwapPromise> swap_promise(
+      new LatencyInfoSwapPromise(latency_info));
+  active_tree()->QueueSwapPromise(swap_promise.Pass());
 }
 
 void LayerTreeHostImpl::TrackDamageForAllSurfaces(
@@ -1269,7 +1272,6 @@
   metadata.root_layer_size = active_tree_->ScrollableSize();
   metadata.min_page_scale_factor = active_tree_->min_page_scale_factor();
   metadata.max_page_scale_factor = active_tree_->max_page_scale_factor();
-  metadata.latency_info = active_tree_->GetLatencyInfo();
   if (top_controls_manager_) {
     metadata.location_bar_offset =
         gfx::Vector2dF(0.f, top_controls_manager_->controls_top_offset());
@@ -1428,9 +1430,8 @@
     return false;
   }
   CompositorFrameMetadata metadata = MakeCompositorFrameMetadata();
+  active_tree()->FinishSwapPromises(&metadata);
   renderer_->SwapBuffers(metadata);
-  active_tree_->ClearLatencyInfo();
-  active_tree()->FinishSwapPromises();
   return true;
 }