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..fa17cf67752e04acd95be212b599341c3d782acb |
| --- /dev/null |
| +++ b/net/log/net_log_capture_mode.h |
| @@ -0,0 +1,91 @@ |
| +// 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/basictypes.h" |
| +#include "net/base/net_export.h" |
| + |
| +namespace net { |
| + |
| +// NetLogCaptureMode specifies the granularity of events that should be emitted |
| +// to the log. It is a simple wrapper around an integer, so it should be passed |
| +// to functions by value rather than by reference. |
| +class NET_EXPORT NetLogCaptureMode { |
| + public: |
| + // NOTE: Default assignment and copy constructor are OK |
| + |
| + // The default constructor creates an empty capture mode (equivalent to |
| + // None()). |
| + NetLogCaptureMode(); |
| + |
| + // If |enabled()| is true, then _something_ is being captured. |
| + bool enabled() const; |
| + |
| + // If |include_private_data()| is true , then it is OK to log events which |
| + // contain cookies, credentials or other privacy sensitive data. |
| + bool include_private_data() const; |
| + |
| + // If |include_socket_bytes()| is true, then it is OK to output the actual |
| + // bytes read/written from the network, even if it contains private data. |
| + bool include_socket_bytes() const; |
| + |
| + // Returns a capture mode that contains the maximal set of capabilities |
| + // between |mode1| and |mode1|. |
|
mmenke
2015/04/17 15:16:06
mode2
eroman
2015/04/17 19:20:50
Done.
|
| + static NetLogCaptureMode Max(NetLogCaptureMode mode1, |
| + NetLogCaptureMode mode2); |
| + |
| + // Constructs a capture mode which logs NOTHING. |
| + // enabled() --> false |
| + // include_private_data() --> false |
| + // include_socket_bytes() --> false |
| + static NetLogCaptureMode None(); |
| + |
| + // Constructs a capture mode which logs basic events and event parameters. |
| + // enabled() --> true |
| + // include_private_data() --> false |
| + // include_socket_bytes() --> false |
| + static NetLogCaptureMode Default(); |
| + |
| + // Constructs a capture mode which logs basic events, and additionally makes |
| + // no effort to strip cookies and credentials. |
| + // enabled() --> true |
| + // include_private_data() --> true |
| + // include_socket_bytes() --> false |
| + static NetLogCaptureMode IncludeCookiesAndCredentials(); |
| + |
| + // Constructs a capture mode which logs absolutely everything possible. |
| + // enabled() --> true |
| + // include_private_data() --> true |
| + // include_socket_bytes() --> true |
| + static NetLogCaptureMode All(); |
| + |
| + bool operator==(NetLogCaptureMode mode) const; |
|
mmenke
2015/04/17 15:16:06
This just for tests, or are there any other uses f
eroman
2015/04/17 19:20:50
This is currently just being used by tests (DCHECK
mmenke
2015/04/20 15:54:38
I'm perfectly happy with it as-is, was just wonder
|
| + |
| + int32_t ToInternalValueForTesting() const { return ToInternalValue(); } |
|
mmenke
2015/04/17 15:16:06
We'll of course need tests for all this stuff.
eroman
2015/04/17 19:20:50
I have attached a new file, net_log_capture_mode_u
|
| + |
| + private: |
| + // NetLog relies on the internal value of NetLogCaptureMode being an integer, |
| + // so it can be read/written atomically across thread. |
| + friend class NetLog; |
| + |
| + explicit NetLogCaptureMode(uint32_t value); |
| + |
| + static NetLogCaptureMode FromInternalValue(int32_t value) { |
| + return NetLogCaptureMode(value); |
| + } |
| + |
| + int32_t ToInternalValue() const { return value_; } |
| + |
| + int32_t value_; |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_LOG_NET_LOG_CAPTURE_MODE_H_ |