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

Unified Diff: net/log/net_log_capture_mode.h

Issue 1059843002: Refactor NetLog::LogLevel --> NetLogCaptureMode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix some translation bugs 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
Index: net/log/net_log_capture_mode.h
diff --git a/net/log/net_log_capture_mode.h b/net/log/net_log_capture_mode.h
new file mode 100644
index 0000000000000000000000000000000000000000..520a9fa0eccd020346f461c90ec407f0729c4e50
--- /dev/null
+++ b/net/log/net_log_capture_mode.h
@@ -0,0 +1,89 @@
+// 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.
+
+#ifndef NET_LOG_NET_LOG_CAPTURE_MODE_H_
+#define NET_LOG_NET_LOG_CAPTURE_MODE_H_
+
+#include <string>
+
+#include "build/build_config.h"
+
+#include "base/atomicops.h"
+#include "base/basictypes.h"
+#include "base/callback_forward.h"
+#include "base/compiler_specific.h"
+#include "base/observer_list.h"
+#include "base/strings/string16.h"
+#include "base/synchronization/lock.h"
+#include "base/time/time.h"
+#include "net/base/net_export.h"
+
+namespace net {
+
+// Specifies the granularity of events that should be emitted to the log.
+//
+// TODO(eroman): Rename:
+// StripPrivateData -> Default()
+// AllButBytes -> IncludeCookiesAndCredentials()
+//
+// TODO(eroman): The "Level" should be an internal detail and not exposed
+// anywhere.
+class NetLogCaptureMode {
+ public:
+ enum Level {
+ // Don't log any events.
+ NONE,
+
+ // Log all events, but do not include the actual transferred bytes and
+ // remove cookies and HTTP credentials.
+ STRIP_PRIVATE_DATA,
+
+ // Log all events, but do not include the actual transferred bytes as
+ // parameters for bytes sent/received events.
+ ALL_BUT_BYTES,
+
+ // Log everything possible, even if it is slow and memory expensive.
+ // Includes logging of transferred bytes.
+ ALL,
+ };
mmenke 2015/04/09 15:47:12 Are these just public for net-internals?
eroman 2015/04/16 22:51:09 Done -- I have now removed these from the public h
+
+ // Default constructor creates an empty capture mode.
+ NetLogCaptureMode() : NetLogCaptureMode(NONE) {}
+
+ // DEPRECATED: Do not use this unless necessary.
+ explicit NetLogCaptureMode(Level level) : level_(level) {}
+
+ bool enabled() const { return level_ != NONE; }
+ bool include_private_data() const { return level_ > STRIP_PRIVATE_DATA; }
+ bool include_socket_bytes() const { return level_ == ALL; }
+
+ // Does a union of the two capture modes.
+ void AddMode(NetLogCaptureMode mode) {
mmenke 2015/04/09 15:47:11 Also, this should either not be inlined, or called
mmenke 2015/04/09 15:47:11 Think an "Add" method that works like max is a lit
eroman 2015/04/16 22:51:09 Done -- I have followed your suggesting, but inste
eroman 2015/04/16 22:51:09 Done -- I have added net_log_caputure_mode.cc and
+ level_ = std::max(level_, mode.level());
+ }
+
+ // Constructs the various capture modes.
+ static NetLogCaptureMode None() { return NetLogCaptureMode(NONE); }
+
+ static NetLogCaptureMode StripPrivateData() {
+ return NetLogCaptureMode(STRIP_PRIVATE_DATA);
+ }
+
+ static NetLogCaptureMode AllButBytes() {
+ return NetLogCaptureMode(ALL_BUT_BYTES);
+ }
+
+ static NetLogCaptureMode All() { return NetLogCaptureMode(ALL); }
mmenke 2015/04/09 15:47:12 Given the naming of these methods, think they prob
eroman 2015/04/16 22:51:09 Done.
+
+ Level level() const { return level_; }
+
+ bool operator==(NetLogCaptureMode o) const { return level() == o.level(); }
mmenke 2015/04/09 15:47:12 "o" violates naming guidelines. Suggest just mode
eroman 2015/04/16 22:51:09 Done.
+
+ private:
+ Level level_;
mmenke 2015/04/09 15:47:12 +Comment about copy and assign being deliberately
eroman 2015/04/16 22:51:09 Done.
+};
+
+} // namespace net
+
+#endif // NET_LOG_NET_LOG_CAPTURE_MODE_H_
« net/log/net_log.cc ('K') | « net/log/net_log.cc ('k') | net/log/net_log_logger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698