Reland "Enable use of rtc::SystemTimeNanos() provided by Chromium"
This reverts commit cd5127b11e04b7f49031b2412625c36e4a86c3da.
Reason for revert: Fuzzer build problems fixed.
Original change's description:
> Revert "Enable use of rtc::SystemTimeNanos() provided by Chromium"
>
> This reverts commit dfe19719e53abfd4d73722942445c5e1046b671b.
>
> Reason for revert: Breaks fuzzers in Chromium builds. See https://ci.chromium.org/ui/p/chromium/builders/try/linux-libfuzzer-asan-rel/685438/overview. I am reverting since this blocks the roll but I will be in touch for a fix.
>
> Original change's description:
> > Enable use of rtc::SystemTimeNanos() provided by Chromium
> >
> > This is the third CL out of three to enable overriding
> > of the function SystemTimeNanos() in rtc_base/system_time.cc
> >
> > When WebRTC is built as part of Chromium the rtc::SystemTimeNanos()
> > function provided by Chromium will be used. This is controlled
> > by the build argument rtc_exclude_system_time which directly
> > maps to the macro WEBRTC_EXCLUDE_SYSTEM_TIME.
> >
> > By doing this we are making sure that the WebRTC and Chromium
> > clocks are the same.
> >
> > Bug: chromium:516700
> > Change-Id: If7f749c4aadefb1cfc07ba4c7e3f45dc6c31118b
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/208223
> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#33337}
>
> TBR=kron@webrtc.org
>
> Bug: chromium:516700
> Change-Id: I9ecd1784a6c1cdac8bae07d34f7df20c62a21a95
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/208740
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#33340}
Bug: chromium:516700
Change-Id: I4cd68bac1cc4befdb46351f5d6fb2cf1ef5c3062
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/208742
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Johannes Kron <kron@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33341}
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index 28ff7fd..32ef93e 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -407,6 +407,10 @@
":stringutils",
"system:rtc_export",
]
+ if (rtc_exclude_system_time) {
+ defines = [ "WEBRTC_EXCLUDE_SYSTEM_TIME" ]
+ }
+
libs = []
if (is_win) {
libs += [ "winmm.lib" ]
diff --git a/rtc_base/system_time.cc b/rtc_base/system_time.cc
index bcd4e6c..9efe76e 100644
--- a/rtc_base/system_time.cc
+++ b/rtc_base/system_time.cc
@@ -8,6 +8,10 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+// If WEBRTC_EXCLUDE_SYSTEM_TIME is set, an implementation of
+// rtc::SystemTimeNanos() must be provided externally.
+#ifndef WEBRTC_EXCLUDE_SYSTEM_TIME
+
#include <stdint.h>
#include <limits>
@@ -90,3 +94,4 @@
}
} // namespace rtc
+#endif // WEBRTC_EXCLUDE_SYSTEM_TIME
diff --git a/rtc_tools/BUILD.gn b/rtc_tools/BUILD.gn
index f6352d8..2020957 100644
--- a/rtc_tools/BUILD.gn
+++ b/rtc_tools/BUILD.gn
@@ -136,6 +136,12 @@
"//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/strings",
]
+
+ if (build_with_chromium) {
+ # When building from Chromium, WebRTC's metrics and field trial
+ # implementations need to be replaced by the Chromium ones.
+ deps += [ "//third_party/webrtc_overrides:webrtc_component" ]
+ }
}
# TODO(bugs.webrtc.org/11474): Enable this on win if needed. For now it
diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn
index af7a4b7..44387ad 100644
--- a/test/fuzzers/BUILD.gn
+++ b/test/fuzzers/BUILD.gn
@@ -18,11 +18,12 @@
]
# When WebRTC fuzzer tests are built on Chromium bots they need to link
- # with Chromium's implementation of metrics and field trial.
+ # with Chromium's implementation of metrics, field trial, and system time.
if (build_with_chromium) {
deps += [
"../../../webrtc_overrides:field_trial",
"../../../webrtc_overrides:metrics",
+ "../../../webrtc_overrides:system_time",
]
}
}
diff --git a/webrtc.gni b/webrtc.gni
index 08b2d66..c1227ba 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -63,7 +63,7 @@
# will tell the pre-processor to remove the default definition of the
# SystemTimeNanos() which is defined in rtc_base/system_time.cc. In
# that case a new implementation needs to be provided.
- rtc_exclude_system_time = false
+ rtc_exclude_system_time = build_with_chromium
# Setting this to false will require the API user to pass in their own
# SSLCertificateVerifier to verify the certificates presented from a