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

Unified Diff: ios/web/navigation/time_smoother.cc

Issue 988383002: Upstream various ios/web utilities and helpers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web-public-upstreaming
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: ios/web/navigation/time_smoother.cc
diff --git a/ios/web/navigation/time_smoother.cc b/ios/web/navigation/time_smoother.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b8aaec68ec3c2e222594fcd7b82f7221fcc26884
--- /dev/null
+++ b/ios/web/navigation/time_smoother.cc
@@ -0,0 +1,25 @@
+// 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 "ios/web/navigation/time_smoother.h"
+
+namespace web {
+
+// Duplicated from content/browser/web_contents/navigation_controller_impl.cc.
+base::Time TimeSmoother::GetSmoothedTime(base::Time t) {
+ // If |t| is between the water marks, we're in a run of duplicates
+ // or just getting out of it, so increase the high-water mark to get
+ // a time that probably hasn't been used before and return it.
+ if (low_water_mark_ <= t && t <= high_water_mark_) {
+ high_water_mark_ += base::TimeDelta::FromMicroseconds(1);
+ return high_water_mark_;
+ }
+
+ // Otherwise, we're clear of the last duplicate run, so reset the
+ // water marks.
+ low_water_mark_ = high_water_mark_ = t;
+ return t;
+}
+
+} // namespace web

Powered by Google App Engine
This is Rietveld 408576698