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/atomicops.h" | |
| 13 #include "base/basictypes.h" | |
| 14 #include "base/callback_forward.h" | |
| 15 #include "base/compiler_specific.h" | |
| 16 #include "base/observer_list.h" | |
| 17 #include "base/strings/string16.h" | |
| 18 #include "base/synchronization/lock.h" | |
| 19 #include "base/time/time.h" | |
| 20 #include "net/base/net_export.h" | |
| 21 | |
| 22 namespace net { | |
|
eroman
2015/04/09 00:08:19
changes here
| |
| 23 | |
| 24 // Specifies the granularity of events that should be emitted to the log. | |
| 25 // | |
| 26 // TODO(eroman): Rename: | |
| 27 // StripPrivateData -> Default() | |
| 28 // AllButBytes -> IncludeCookiesAndCredentials() | |
| 29 // | |
| 30 // TODO(eroman): The "Level" should be an internal detail and not exposed | |
| 31 // anywhere. | |
| 32 class NetLogCaptureMode { | |
| 33 public: | |
| 34 enum Level { | |
| 35 // Don't log any events. | |
| 36 NONE, | |
| 37 | |
| 38 // Log all events, but do not include the actual transferred bytes and | |
| 39 // remove cookies and HTTP credentials. | |
| 40 STRIP_PRIVATE_DATA, | |
| 41 | |
| 42 // Log all events, but do not include the actual transferred bytes as | |
| 43 // parameters for bytes sent/received events. | |
| 44 ALL_BUT_BYTES, | |
| 45 | |
| 46 // Log everything possible, even if it is slow and memory expensive. | |
| 47 // Includes logging of transferred bytes. | |
| 48 ALL, | |
| 49 }; | |
| 50 | |
| 51 // Default constructor creates an empty capture mode. | |
| 52 NetLogCaptureMode() : NetLogCaptureMode(NONE) {} | |
| 53 | |
| 54 // DEPRECATED: Do not use this unless necessary. | |
| 55 explicit NetLogCaptureMode(Level level) : level_(level) {} | |
| 56 | |
| 57 bool enabled() const { return level_ != NONE; } | |
| 58 bool include_private_data() const { return level_ > STRIP_PRIVATE_DATA; } | |
| 59 bool include_socket_bytes() const { return level_ == ALL; } | |
| 60 | |
| 61 // Does a union of the two capture modes. | |
| 62 void AddMode(NetLogCaptureMode mode) { | |
| 63 level_ = std::max(level_, mode.level()); | |
| 64 } | |
| 65 | |
| 66 // Constructs the various capture modes. | |
| 67 static NetLogCaptureMode None() { return NetLogCaptureMode(NONE); } | |
| 68 | |
| 69 static NetLogCaptureMode StripPrivateData() { | |
| 70 return NetLogCaptureMode(STRIP_PRIVATE_DATA); | |
| 71 } | |
| 72 | |
| 73 static NetLogCaptureMode AllButBytes() { | |
| 74 return NetLogCaptureMode(ALL_BUT_BYTES); | |
| 75 } | |
| 76 | |
| 77 static NetLogCaptureMode All() { return NetLogCaptureMode(ALL); } | |
| 78 | |
| 79 Level level() const { return level_; } | |
| 80 | |
| 81 bool operator==(NetLogCaptureMode o) const { return level() == o.level(); } | |
| 82 | |
| 83 private: | |
| 84 Level level_; | |
| 85 }; | |
| 86 | |
| 87 } // namespace net | |
| 88 | |
| 89 #endif // NET_LOG_NET_LOG_CAPTURE_MODE_H_ | |
| OLD | NEW |