DevTools: kill codeschool extension from whitelist
[chromium-blink-merge.git] / net / log / net_log_capture_mode.cc
blob501911e0a9b6dc7b063e219350919942276a54e9
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.
5 #include "net/log/net_log_capture_mode.h"
7 #include <algorithm>
9 namespace net {
11 namespace {
13 // Integer representation for the capture mode. The numeric value is depended on
14 // for method of NetLogCaptureMode, which expect that higher values imply more
15 // capabilities.
16 enum InternalValue {
17 // Don't log any events.
18 NONE,
20 // Log all events, but do not include the actual transferred bytes and
21 // remove cookies and HTTP credentials.
22 DEFAULT,
24 // Log all events, but do not include the actual transferred bytes as
25 // parameters for bytes sent/received events.
26 INCLUDE_COOKIES_AND_CREDENTIALS,
28 // Log everything possible, even if it is slow and memory expensive.
29 // Includes logging of transferred bytes.
30 INCLUDE_SOCKET_BYTES,
33 } // namespace
35 // Default constructor creates an empty capture mode.
36 NetLogCaptureMode::NetLogCaptureMode() : NetLogCaptureMode(NONE) {
39 NetLogCaptureMode NetLogCaptureMode::None() {
40 return NetLogCaptureMode(NONE);
43 NetLogCaptureMode NetLogCaptureMode::Default() {
44 return NetLogCaptureMode(DEFAULT);
47 NetLogCaptureMode NetLogCaptureMode::IncludeCookiesAndCredentials() {
48 return NetLogCaptureMode(INCLUDE_COOKIES_AND_CREDENTIALS);
51 NetLogCaptureMode NetLogCaptureMode::IncludeSocketBytes() {
52 return NetLogCaptureMode(INCLUDE_SOCKET_BYTES);
55 NetLogCaptureMode NetLogCaptureMode::Max(NetLogCaptureMode mode1,
56 NetLogCaptureMode mode2) {
57 return NetLogCaptureMode(std::max(mode1.value_, mode2.value_));
60 bool NetLogCaptureMode::enabled() const {
61 return value_ != NONE;
64 bool NetLogCaptureMode::include_cookies_and_credentials() const {
65 return value_ >= INCLUDE_COOKIES_AND_CREDENTIALS;
68 bool NetLogCaptureMode::include_socket_bytes() const {
69 return value_ >= INCLUDE_SOCKET_BYTES;
72 bool NetLogCaptureMode::operator==(NetLogCaptureMode mode) const {
73 return value_ == mode.value_;
76 bool NetLogCaptureMode::operator!=(NetLogCaptureMode mode) const {
77 return !(*this == mode);
80 int32_t NetLogCaptureMode::ToInternalValueForTesting() const {
81 return ToInternalValue();
84 NetLogCaptureMode::NetLogCaptureMode(uint32_t value) : value_(value) {
87 NetLogCaptureMode NetLogCaptureMode::FromInternalValue(int32_t value) {
88 return NetLogCaptureMode(value);
91 int32_t NetLogCaptureMode::ToInternalValue() const {
92 return value_;
95 } // namespace net