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

Unified Diff: net/log/net_log_capture_mode.cc

Issue 1059843002: Refactor NetLog::LogLevel --> NetLogCaptureMode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again to fix a merge conflict Created 5 years, 8 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
« no previous file with comments | « net/log/net_log_capture_mode.h ('k') | net/log/net_log_capture_mode_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/log/net_log_capture_mode.cc
diff --git a/net/log/net_log_capture_mode.cc b/net/log/net_log_capture_mode.cc
new file mode 100644
index 0000000000000000000000000000000000000000..501911e0a9b6dc7b063e219350919942276a54e9
--- /dev/null
+++ b/net/log/net_log_capture_mode.cc
@@ -0,0 +1,95 @@
+// Copyright 2015 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 "net/log/net_log_capture_mode.h"
+
+#include <algorithm>
+
+namespace net {
+
+namespace {
+
+// Integer representation for the capture mode. The numeric value is depended on
+// for method of NetLogCaptureMode, which expect that higher values imply more
+// capabilities.
+enum InternalValue {
+ // Don't log any events.
+ NONE,
+
+ // Log all events, but do not include the actual transferred bytes and
+ // remove cookies and HTTP credentials.
+ DEFAULT,
+
+ // Log all events, but do not include the actual transferred bytes as
+ // parameters for bytes sent/received events.
+ INCLUDE_COOKIES_AND_CREDENTIALS,
+
+ // Log everything possible, even if it is slow and memory expensive.
+ // Includes logging of transferred bytes.
+ INCLUDE_SOCKET_BYTES,
+};
+
+} // namespace
+
+// Default constructor creates an empty capture mode.
+NetLogCaptureMode::NetLogCaptureMode() : NetLogCaptureMode(NONE) {
+}
+
+NetLogCaptureMode NetLogCaptureMode::None() {
+ return NetLogCaptureMode(NONE);
+}
+
+NetLogCaptureMode NetLogCaptureMode::Default() {
+ return NetLogCaptureMode(DEFAULT);
+}
+
+NetLogCaptureMode NetLogCaptureMode::IncludeCookiesAndCredentials() {
+ return NetLogCaptureMode(INCLUDE_COOKIES_AND_CREDENTIALS);
+}
+
+NetLogCaptureMode NetLogCaptureMode::IncludeSocketBytes() {
+ return NetLogCaptureMode(INCLUDE_SOCKET_BYTES);
+}
+
+NetLogCaptureMode NetLogCaptureMode::Max(NetLogCaptureMode mode1,
+ NetLogCaptureMode mode2) {
+ return NetLogCaptureMode(std::max(mode1.value_, mode2.value_));
+}
+
+bool NetLogCaptureMode::enabled() const {
+ return value_ != NONE;
+}
+
+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);
+}
+
+int32_t NetLogCaptureMode::ToInternalValueForTesting() const {
+ return ToInternalValue();
+}
+
+NetLogCaptureMode::NetLogCaptureMode(uint32_t value) : value_(value) {
+}
+
+NetLogCaptureMode NetLogCaptureMode::FromInternalValue(int32_t value) {
+ return NetLogCaptureMode(value);
+}
+
+int32_t NetLogCaptureMode::ToInternalValue() const {
+ return value_;
+}
+
+} // namespace net
« no previous file with comments | « net/log/net_log_capture_mode.h ('k') | net/log/net_log_capture_mode_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698