Chromium Code Reviews| 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 { |
|
eroman
2015/04/09 00:08:19
changes here
|
| + |
| +// 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, |
| + }; |
| + |
| + // 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) { |
| + 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); } |
| + |
| + Level level() const { return level_; } |
| + |
| + bool operator==(NetLogCaptureMode o) const { return level() == o.level(); } |
| + |
| + private: |
| + Level level_; |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_LOG_NET_LOG_CAPTURE_MODE_H_ |