Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_LOG_NET_LOG_CAPTURE_MODE_H_ | |
| 6 #define NET_LOG_NET_LOG_CAPTURE_MODE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "build/build_config.h" | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "net/base/net_export.h" | |
| 14 | |
| 15 namespace net { | |
| 16 | |
| 17 // NetLogCaptureMode specifies the granularity of events that should be emitted | |
| 18 // to the log. It is a simple wrapper around an integer, so it should be passed | |
| 19 // to functions by value rather than by reference. | |
| 20 class NET_EXPORT NetLogCaptureMode { | |
| 21 public: | |
| 22 // NOTE: Default assignment and copy constructor are OK | |
| 23 | |
| 24 // The default constructor creates an empty capture mode (equivalent to | |
| 25 // None()). | |
| 26 NetLogCaptureMode(); | |
| 27 | |
| 28 // If |enabled()| is true, then _something_ is being captured. | |
| 29 bool enabled() const; | |
| 30 | |
| 31 // If |include_private_data()| is true , then it is OK to log events which | |
| 32 // contain cookies, credentials or other privacy sensitive data. | |
| 33 bool include_private_data() const; | |
| 34 | |
| 35 // If |include_socket_bytes()| is true, then it is OK to output the actual | |
| 36 // bytes read/written from the network, even if it contains private data. | |
| 37 bool include_socket_bytes() const; | |
| 38 | |
| 39 // Returns a capture mode that contains the maximal set of capabilities | |
| 40 // between |mode1| and |mode1|. | |
|
mmenke
2015/04/17 15:16:06
mode2
eroman
2015/04/17 19:20:50
Done.
| |
| 41 static NetLogCaptureMode Max(NetLogCaptureMode mode1, | |
| 42 NetLogCaptureMode mode2); | |
| 43 | |
| 44 // Constructs a capture mode which logs NOTHING. | |
| 45 // enabled() --> false | |
| 46 // include_private_data() --> false | |
| 47 // include_socket_bytes() --> false | |
| 48 static NetLogCaptureMode None(); | |
| 49 | |
| 50 // Constructs a capture mode which logs basic events and event parameters. | |
| 51 // enabled() --> true | |
| 52 // include_private_data() --> false | |
| 53 // include_socket_bytes() --> false | |
| 54 static NetLogCaptureMode Default(); | |
| 55 | |
| 56 // Constructs a capture mode which logs basic events, and additionally makes | |
| 57 // no effort to strip cookies and credentials. | |
| 58 // enabled() --> true | |
| 59 // include_private_data() --> true | |
| 60 // include_socket_bytes() --> false | |
| 61 static NetLogCaptureMode IncludeCookiesAndCredentials(); | |
| 62 | |
| 63 // Constructs a capture mode which logs absolutely everything possible. | |
| 64 // enabled() --> true | |
| 65 // include_private_data() --> true | |
| 66 // include_socket_bytes() --> true | |
| 67 static NetLogCaptureMode All(); | |
| 68 | |
| 69 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
| |
| 70 | |
| 71 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
| |
| 72 | |
| 73 private: | |
| 74 // NetLog relies on the internal value of NetLogCaptureMode being an integer, | |
| 75 // so it can be read/written atomically across thread. | |
| 76 friend class NetLog; | |
| 77 | |
| 78 explicit NetLogCaptureMode(uint32_t value); | |
| 79 | |
| 80 static NetLogCaptureMode FromInternalValue(int32_t value) { | |
| 81 return NetLogCaptureMode(value); | |
| 82 } | |
| 83 | |
| 84 int32_t ToInternalValue() const { return value_; } | |
| 85 | |
| 86 int32_t value_; | |
| 87 }; | |
| 88 | |
| 89 } // namespace net | |
| 90 | |
| 91 #endif // NET_LOG_NET_LOG_CAPTURE_MODE_H_ | |
| OLD | NEW |