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

Unified Diff: cc/base/latency_info_swap_promise.cc

Issue 81533002: Use LatencyInfoSwapPromise to track LatencyInfo through compositor (Closed) Base URL: http://git.chromium.org/chromium/src.git@swap_promise_2
Patch Set: remove |type| from SwapPromise Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/base/latency_info_swap_promise.h ('k') | cc/base/swap_promise.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/latency_info_swap_promise.cc
diff --git a/cc/base/latency_info_swap_promise.cc b/cc/base/latency_info_swap_promise.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6a02c8bfcabc725d1fc6a3a84b87973f25395b98
--- /dev/null
+++ b/cc/base/latency_info_swap_promise.cc
@@ -0,0 +1,53 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/base/latency_info_swap_promise.h"
+
+#include "base/logging.h"
+
+namespace {
+ ui::LatencyComponentType DidNotSwapReasonToLatencyComponentType(
+ cc::SwapPromise::DidNotSwapReason reason) {
+ switch (reason) {
+ case cc::SwapPromise::DID_NOT_SWAP_UNKNOWN:
+ case cc::SwapPromise::SWAP_FAILS:
+ return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT;
+ break;
danakj 2013/11/27 20:26:10 nit: break is kinda pointless after a return state
Yufeng Shen (Slow to review) 2013/11/27 21:19:34 Done.
+ case cc::SwapPromise::COMMIT_FAILS:
+ return ui::INPUT_EVENT_LATENCY_TERMINATED_COMMIT_FAILED_COMPONENT;
+ break;
+ case cc::SwapPromise::SWAP_PROMISE_LIST_OVERFLOW:
+ return ui::LATENCY_INFO_LIST_TERMINATED_OVERFLOW_COMPONENT;
+ break;
+ default:
+ DLOG(WARNING) << "Unhandled DidNotSwapReason.\n";
danakj 2013/11/27 20:26:10 Should this be a NOTREACHED()?
danakj 2013/11/27 20:26:10 Generally you don't need \n at the end of LOG line
Yufeng Shen (Slow to review) 2013/11/27 21:19:34 Done.
Yufeng Shen (Slow to review) 2013/11/27 21:19:34 Done.
+ break;
+ }
+ return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT;
+ }
+} // namespace
+
+namespace cc {
+
+LatencyInfoSwapPromise::LatencyInfoSwapPromise(const ui::LatencyInfo& latency)
+ : latency_(latency) {
+}
+
+LatencyInfoSwapPromise::~LatencyInfoSwapPromise() {
+}
+
+void LatencyInfoSwapPromise::DidSwap(CompositorFrameMetadata* metadata) {
+ DCHECK(!latency_.terminated);
+ // TODO(mileus): Append the |latency_| into metadata's LatencyInfo list
+ // once we remove LatencyInfo merge in GPU side.
+ metadata->latency_info.MergeWith(latency_);
+}
+
+void LatencyInfoSwapPromise::DidNotSwap(DidNotSwapReason reason) {
+ latency_.AddLatencyNumber(DidNotSwapReasonToLatencyComponentType(reason),
+ 0, 0);
+ DCHECK(latency_.terminated);
+}
+
+} // namespace cc
« no previous file with comments | « cc/base/latency_info_swap_promise.h ('k') | cc/base/swap_promise.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698