Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: net/log/net_log_capture_mode.cc

Issue 1059843002: Refactor NetLog::LogLevel --> NetLogCaptureMode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again to fix a merge conflict Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/log/net_log_capture_mode.h ('k') | net/log/net_log_capture_mode_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "net/log/net_log_capture_mode.h"
6
7 #include <algorithm>
8
9 namespace net {
10
11 namespace {
12
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,
19
20 // Log all events, but do not include the actual transferred bytes and
21 // remove cookies and HTTP credentials.
22 DEFAULT,
23
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,
27
28 // Log everything possible, even if it is slow and memory expensive.
29 // Includes logging of transferred bytes.
30 INCLUDE_SOCKET_BYTES,
31 };
32
33 } // namespace
34
35 // Default constructor creates an empty capture mode.
36 NetLogCaptureMode::NetLogCaptureMode() : NetLogCaptureMode(NONE) {
37 }
38
39 NetLogCaptureMode NetLogCaptureMode::None() {
40 return NetLogCaptureMode(NONE);
41 }
42
43 NetLogCaptureMode NetLogCaptureMode::Default() {
44 return NetLogCaptureMode(DEFAULT);
45 }
46
47 NetLogCaptureMode NetLogCaptureMode::IncludeCookiesAndCredentials() {
48 return NetLogCaptureMode(INCLUDE_COOKIES_AND_CREDENTIALS);
49 }
50
51 NetLogCaptureMode NetLogCaptureMode::IncludeSocketBytes() {
52 return NetLogCaptureMode(INCLUDE_SOCKET_BYTES);
53 }
54
55 NetLogCaptureMode NetLogCaptureMode::Max(NetLogCaptureMode mode1,
56 NetLogCaptureMode mode2) {
57 return NetLogCaptureMode(std::max(mode1.value_, mode2.value_));
58 }
59
60 bool NetLogCaptureMode::enabled() const {
61 return value_ != NONE;
62 }
63
64 bool NetLogCaptureMode::include_cookies_and_credentials() const {
65 return value_ >= INCLUDE_COOKIES_AND_CREDENTIALS;
66 }
67
68 bool NetLogCaptureMode::include_socket_bytes() const {
69 return value_ >= INCLUDE_SOCKET_BYTES;
70 }
71
72 bool NetLogCaptureMode::operator==(NetLogCaptureMode mode) const {
73 return value_ == mode.value_;
74 }
75
76 bool NetLogCaptureMode::operator!=(NetLogCaptureMode mode) const {
77 return !(*this == mode);
78 }
79
80 int32_t NetLogCaptureMode::ToInternalValueForTesting() const {
81 return ToInternalValue();
82 }
83
84 NetLogCaptureMode::NetLogCaptureMode(uint32_t value) : value_(value) {
85 }
86
87 NetLogCaptureMode NetLogCaptureMode::FromInternalValue(int32_t value) {
88 return NetLogCaptureMode(value);
89 }
90
91 int32_t NetLogCaptureMode::ToInternalValue() const {
92 return value_;
93 }
94
95 } // namespace net
OLDNEW
« no previous file with comments | « net/log/net_log_capture_mode.h ('k') | net/log/net_log_capture_mode_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698