Commit graph

21 commits

Author SHA1 Message Date
Ali Tofigh
7fa9057a05 Adopt absl::string_view in function parameters under rtc_base/
This is part of a large-scale effort to increase adoption of
absl::string_view across the WebRTC code base.

This CL converts the majority of "const std::string&"s in function
parameters under rtc_base/ to absl::string_view.

Bug: webrtc:13579
Change-Id: I2b1e3776aa42326aa405f76bb324a2d233b21dca
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254081
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Xavier Lepaul‎ <xalep@webrtc.org>
Reviewed-by: Anders Lilienthal <andersc@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36239}
2022-03-17 15:39:26 +00:00
Niels Möller
b02220d1a0 Reland "Mark all bool conversion operators as explicit"
This is a reland of 325789c457

Original change's description:
> Mark all bool conversion operators as explicit
>
> An explicit bool conversion operator will still be used implicitly
> when an expression appears in "bool context", e.g., as the condition
> in an if statement, or as argument to logical operators. The
> `explicit` annotation prevents conversion in other contexts, e.g.,
> converting both a and b to bool in an expression like `a == b`.
>
> Bug: None
> Change-Id: I79ef35b1ea831e6011ae472900375ae8a3e617ab
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250664
> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Commit-Queue: Niels Moller <nisse@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#35927}

Bug: None
Change-Id: Ie057dfc8c0b5c498e2c8daff7620172c89f0e011
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251380
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35962}
2022-02-09 09:40:05 +00:00
Mirko Bonadei
c1fd46f879 Revert "Mark all bool conversion operators as explicit"
This reverts commit 325789c457.

Reason for revert: Breaks downstream clients.

Original change's description:
> Mark all bool conversion operators as explicit
>
> An explicit bool conversion operator will still be used implicitly
> when an expression appears in "bool context", e.g., as the condition
> in an if statement, or as argument to logical operators. The
> `explicit` annotation prevents conversion in other contexts, e.g.,
> converting both a and b to bool in an expression like `a == b`.
>
> Bug: None
> Change-Id: I79ef35b1ea831e6011ae472900375ae8a3e617ab
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250664
> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Commit-Queue: Niels Moller <nisse@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#35927}

TBR=mbonadei@webrtc.org,nisse@webrtc.org,tommi@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I392cd0c7bd96c90e0db20831864418adb7d58bc3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: None
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251080
Auto-Submit: Mirko Bonadei <mbonadei@webrtc.org>
Owners-Override: Mirko Bonadei <mbonadei@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35929}
2022-02-07 10:24:45 +00:00
Niels Möller
325789c457 Mark all bool conversion operators as explicit
An explicit bool conversion operator will still be used implicitly
when an expression appears in "bool context", e.g., as the condition
in an if statement, or as argument to logical operators. The
`explicit` annotation prevents conversion in other contexts, e.g.,
converting both a and b to bool in an expression like `a == b`.

Bug: None
Change-Id: I79ef35b1ea831e6011ae472900375ae8a3e617ab
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250664
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35927}
2022-02-07 09:14:05 +00:00
Danil Chapovalov
1b320f8b7d Speed up field trial parser for large inputs
Change search for next separator to be linear in length of the string
(instead of potentially quadratic)
Reduce copying of std::string by switch to string_view
Throttle logging about unknown key.

Bug: b/204541739
Change-Id: I81d5cd4432966a0a5808077f9001bc62960e5e60
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/237500
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Fanny Linderborg <linderborg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35330}
2021-11-10 12:31:34 +00:00
Philip Eliasson
29ab487ea7 Revert "Removes string support in field trial parser."
This reverts commit e74156f7d0.

Reason for revert: This turned out to be useful :)

Original change's description:
> Removes string support in field trial parser.
> 
> This prepares for simplifying the behavior of optionals so that
> an empty parameter value resets the optional.
> 
> Bug: webrtc:9883
> Change-Id: I8ef8fe9698235044cac66bc4a587abe874c8f854
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150883
> Commit-Queue: Sebastian Jansson <srte@webrtc.org>
> Reviewed-by: Björn Terelius <terelius@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#29061}

TBR=terelius@webrtc.org,srte@webrtc.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: webrtc:9883
Change-Id: Idbb4061f4b423987e62f3a9ad9bee2410e2cec96
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/152383
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29137}
2019-09-10 14:39:55 +00:00
Sebastian Jansson
e74156f7d0 Removes string support in field trial parser.
This prepares for simplifying the behavior of optionals so that
an empty parameter value resets the optional.

Bug: webrtc:9883
Change-Id: I8ef8fe9698235044cac66bc4a587abe874c8f854
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150883
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29061}
2019-09-04 11:26:24 +00:00
Bjorn Terelius
9f00f0e533 Add support for unsigned parameters in FieldTrialParser
Bug: webrtc:10932
Change-Id: I3f56244a6be532065e4096cf1a289e27a032bc44
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150886
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29018}
2019-08-30 08:23:37 +00:00
Sebastian Jansson
0ee8008a0d Use struct parser for rate control trial.
Bug: webrtc:9883
Change-Id: I9ec7988da2e4d88bedd9b71cae00452f531980d6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/148581
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Jonas Olsson <jonasolsson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28856}
2019-08-14 11:47:12 +00:00
Sebastian Jansson
55251c3d49 Adds struct parameters parser/encoder.
This is similar to the field trial parser but it uses a normal struct
with normal fields as underlying storage. This makes it easier to
understand and use as only the encoding and parsing uses non-
standard constructs. Additionally, it makes it easier to use the
struct as a regular config struct when the values are not set
using field trials.

Bug: webrtc:9883
Change-Id: I5b16c2a71875b6f478383decff18fbaa62bc404a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145203
Reviewed-by: Jonas Olsson <jonasolsson@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28810}
2019-08-08 15:21:35 +00:00
Sebastian Jansson
e670fd9795 Adds getter for FieldTrialParameter keys.
This is useful in test tooling.

Bug: webrtc:9346
Change-Id: I4a2ac52927cfe72f392f8748d3bada1e88db1b6a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/134209
Reviewed-by: Jonas Olsson <jonasolsson@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27786}
2019-04-26 12:53:24 +00:00
Jonas Olsson
97d84ef78e Add support for lists to the FieldTrialParser.
List elements are separated by a |. If the key is given without a : we
treat that as a empty list.

We also support parsing multiple lists as a list-of-structs, see the
unit test for usage examples.

Bug: webrtc:9346
Change-Id: I32d3ce612fef476b1c481c00a893d7fa2f339e92
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130464
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27560}
2019-04-11 11:15:26 +00:00
Sebastian Jansson
1c4547d1f9 Adds SetForTest method on FieldTrialParameter class.
This is useful in tests as it allows overriding the default after
construction. It's not intended for use in production (as it can
be confusing to readers).

Bug: webrtc:10365
Change-Id: I8ac2541f2626e7fddbb61bdae72e9571ce9d7b97
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130468
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Jonas Olsson <jonasolsson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27389}
2019-04-01 12:29:05 +00:00
Jonas Olsson
cb96809e46 Make FieldTrialOptionals operator bool() explicit
Implicit bool conversions behave wierdly in a bunch of cases, so let's make it explicit.

Bug: None
Change-Id: I15933e90d57c57218eed9608407aace5a640a6ea
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/127284
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27076}
2019-03-12 14:24:48 +00:00
Sebastian Jansson
d69998aa5c Adds support for empty key fields in field trial parser.
Bug: webrtc:9346
Change-Id: I16e068340d3d48b983270af0c481ed538632e148
Reviewed-on: https://webrtc-review.googlesource.com/c/115241
Reviewed-by: Christoffer Rodbro <crodbro@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26070}
2018-12-20 13:03:01 +00:00
Sebastian Jansson
b22f077a60 Adds FieldTrialConstrained class.
Bug: webrtc:9346
Change-Id: I8ac232f012cae1d1bd9d862a572aba82bb8ca031
Reviewed-on: https://webrtc-review.googlesource.com/c/111255
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Christoffer Rodbro <crodbro@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25700}
2018-11-19 17:21:55 +00:00
Sebastian Jansson
343f4144be Allows copy and assignment of field trial parameters.
Bug: webrtc:9346
Change-Id: I7734fbe60f95e554a636946cadc1940a78419951
Reviewed-on: https://webrtc-review.googlesource.com/c/104020
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25031}
2018-10-06 15:32:04 +00:00
Sebastian Jansson
fea4637cfe Adds check for unused field trial parameters.
This adds a dcheck to detect if a FieldTrialParameter has been created
but not used in parsing a field trial. This is an easy mistake to make
and cause extra work debugging why nothing happens.

Also improving the ergonomics of using the parameter and optional
classes. Making it easier to use them as drop in replacements for their
underlying classes. In particular, the optional parameter class
implements and interface more similar to the optional class.

Bug: webrtc:9510
Change-Id: I5a12dd66396fa4cac9c9cf517172ae2f06984060
Reviewed-on: https://webrtc-review.googlesource.com/96761
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24527}
2018-09-03 08:52:51 +00:00
Sebastian Jansson
2c74d85c16 Adds enum field trial parser.
Removed the need to create a custom parser function and reuses some of
the code to reduce binary overhead of enums.

Bug: webrtc:9346
Change-Id: I51c9da713ed5456a86a2afbcf0991477bb83b894
Reviewed-on: https://webrtc-review.googlesource.com/83623
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23752}
2018-06-27 08:54:00 +00:00
Danil Chapovalov
0a1d189e50 Replace rtc::Optional with absl::optional in rtc_base
This is a no-op change because rtc::Optional is an alias to absl::optional

This CL generated by running script with parameter 'rtc_base'
Then manually fix where Optional was used without rtc prefix (patchset#3)

find $@ -type f \( -name \*.h -o -name \*.cc \) \
-exec sed -i 's|rtc::Optional|absl::optional|g' {} \+ \
-exec sed -i 's|rtc::nullopt|absl::nullopt|g' {} \+ \
-exec sed -i 's|#include "api/optional.h"|#include "absl/types/optional.h"|' {} \+

find $@ -type f -name BUILD.gn \
-exec sed -r -i 's|"[\./api]*:optional"|"//third_party/abseil-cpp/absl/types:optional"|' {} \+;

git cl format

Bug: webrtc:9078
Change-Id: I825f80cc8089747876ba6316d9e7c30e05716974
Reviewed-on: https://webrtc-review.googlesource.com/84585
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23700}
2018-06-21 11:23:40 +00:00
Sebastian Jansson
9eb38866cd Adds field trial parser.
Bug: webrtc:9346
Change-Id: Ibd07a1753feaa40d4be4d465d61f55bc8a8a9325
Reviewed-on: https://webrtc-review.googlesource.com/80263
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Christoffer Rodbro <crodbro@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23615}
2018-06-14 16:02:38 +00:00