Make NetLogCaptureMode an enum.
Historically the capture mode had aspirations for more complex parameterization, but in practice it just an enum.
Refactored the code to reflect this, and also simplified the symbolic names.
This is strictly a code refactor, except for one user-visible change:
The command line switch --net-log-capture-mode now accepts both the old and new names.
TBR: [email protected],[email protected],[email protected],[email protected],[email protected]
Change-Id: I9bce3f7425bf47e8b24063dc922c534c2aa1f21f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1685684
Reviewed-by: Sean Topping <[email protected]>
Reviewed-by: Scott Graham <[email protected]>
Reviewed-by: Richard Coles <[email protected]>
Reviewed-by: Kinuko Yasuda <[email protected]>
Reviewed-by: David Benjamin <[email protected]>
Commit-Queue: Eric Roman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#676139}
diff --git a/net/log/net_log_capture_mode.cc b/net/log/net_log_capture_mode.cc
index 9b00247e..40b072a 100644
--- a/net/log/net_log_capture_mode.cc
+++ b/net/log/net_log_capture_mode.cc
@@ -6,60 +6,12 @@
namespace net {
-namespace {
-
-// Integer representation for the capture mode. The numeric value is depended on
-// for methods of NetLogCaptureMode, which expect that higher values represent a
-// strict superset of the capabilities of lower values.
-enum InternalValue {
- // Log all events, but do not include the actual transferred bytes, and
- // remove cookies and HTTP credentials and HTTP/2 GOAWAY frame debug data.
- DEFAULT,
-
- // Log all events, but do not include the actual transferred bytes as
- // parameters for bytes sent/received events.
- // TODO(bnc): Consider renaming to INCLUDE_PRIVACY_INFO.
- INCLUDE_COOKIES_AND_CREDENTIALS,
-
- // Log everything possible, even if it is slow and memory expensive.
- // Includes logging of transferred bytes.
- INCLUDE_SOCKET_BYTES,
-};
-
-} // namespace
-
-NetLogCaptureMode::NetLogCaptureMode() : NetLogCaptureMode(DEFAULT) {
+bool NetLogCaptureIncludesSensitive(NetLogCaptureMode capture_mode) {
+ return capture_mode >= NetLogCaptureMode::kIncludeSensitive;
}
-NetLogCaptureMode NetLogCaptureMode::Default() {
- return NetLogCaptureMode(DEFAULT);
-}
-
-NetLogCaptureMode NetLogCaptureMode::IncludeCookiesAndCredentials() {
- return NetLogCaptureMode(INCLUDE_COOKIES_AND_CREDENTIALS);
-}
-
-NetLogCaptureMode NetLogCaptureMode::IncludeSocketBytes() {
- return NetLogCaptureMode(INCLUDE_SOCKET_BYTES);
-}
-
-bool NetLogCaptureMode::include_cookies_and_credentials() const {
- return value_ >= INCLUDE_COOKIES_AND_CREDENTIALS;
-}
-
-bool NetLogCaptureMode::include_socket_bytes() const {
- return value_ >= INCLUDE_SOCKET_BYTES;
-}
-
-bool NetLogCaptureMode::operator==(NetLogCaptureMode mode) const {
- return value_ == mode.value_;
-}
-
-bool NetLogCaptureMode::operator!=(NetLogCaptureMode mode) const {
- return !(*this == mode);
-}
-
-NetLogCaptureMode::NetLogCaptureMode(uint32_t value) : value_(value) {
+bool NetLogCaptureIncludesSocketBytes(NetLogCaptureMode capture_mode) {
+ return capture_mode == NetLogCaptureMode::kEverything;
}
} // namespace net