Make NetLogCaptureMode an enum.
Historically the capture mode had aspirations for more complex parameterization, but in practice it just an enum. Refactored the code to reflect this, and also simplified the symbolic names. This is strictly a code refactor, except for one user-visible change: The command line switch --net-log-capture-mode now accepts both the old and new names. TBR: peter@chromium.org,seantopping@chromium.org,garykac@chromium.org,torne@chromium.org,scottmg@chromium.org Change-Id: I9bce3f7425bf47e8b24063dc922c534c2aa1f21f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1685684 Reviewed-by: Sean Topping <seantopping@chromium.org> Reviewed-by: Scott Graham <scottmg@chromium.org> Reviewed-by: Richard Coles <torne@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: David Benjamin <davidben@chromium.org> Commit-Queue: Eric Roman <eroman@chromium.org> Cr-Commit-Position: refs/heads/master@{#676139}
This commit is contained in:
android_webview/browser/net
chrome/browser
chromecast/browser
components
cronet
net_log
content/browser
fuchsia/engine/browser
google_apis/gcm/tools
ios/chrome/browser/ui/webui/net_export
net
cert
ct_signed_certificate_timestamp_log_param.hmulti_threaded_cert_verifier.ccx509_certificate_net_log_param.h
cookies
dns
extras
http
bidirectional_stream_unittest.cchttp_auth_handler_negotiate.cchttp_log_util.cchttp_log_util_unittest.cchttp_request_headers.hhttp_response_headers.h
log
file_net_log_observer.hfile_net_log_observer_unittest.ccnet_log.ccnet_log_capture_mode.ccnet_log_capture_mode.hnet_log_capture_mode_unittest.ccnet_log_unittest.ccnet_log_util.ccnet_log_with_source.cctest_net_log.cctest_net_log.htrace_net_log_observer.cc
proxy_resolution
socket
spdy
url_request
remoting/base
services/network
@ -247,7 +247,7 @@ AwURLRequestContextGetter::AwURLRequestContextGetter(
|
||||
file_net_log_observer_ = net::FileNetLogObserver::CreateUnbounded(
|
||||
net_log_path, std::move(constants_dict));
|
||||
file_net_log_observer_->StartObserving(net_log_,
|
||||
net::NetLogCaptureMode::Default());
|
||||
net::NetLogCaptureMode::kDefault);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,9 +67,9 @@ class LogNetLogTest : public InProcessBrowserTest,
|
||||
|
||||
// Verify that cookies were stripped when the --net-log-capture-mode flag
|
||||
// was omitted, and not stripped when it was given a value of
|
||||
// IncludeCookiesAndCredentials
|
||||
bool include_cookies = GetParam() && base::StringPiece(GetParam()) ==
|
||||
"IncludeCookiesAndCredentials";
|
||||
// IncludeSensitive
|
||||
bool include_cookies =
|
||||
GetParam() && base::StringPiece(GetParam()) == "IncludeSensitive";
|
||||
|
||||
if (include_cookies) {
|
||||
EXPECT_TRUE(file_contents.find("Set-Cookie: name=Good;Max-Age=3600") !=
|
||||
@ -88,8 +88,7 @@ class LogNetLogTest : public InProcessBrowserTest,
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(,
|
||||
LogNetLogTest,
|
||||
::testing::Values(nullptr,
|
||||
"IncludeCookiesAndCredentials"));
|
||||
::testing::Values(nullptr, "IncludeSensitive"));
|
||||
|
||||
IN_PROC_BROWSER_TEST_P(LogNetLogTest, Basic) {
|
||||
ASSERT_TRUE(embedded_test_server()->Start());
|
||||
|
@ -216,7 +216,7 @@ void NetExportMessageHandler::OnStartNetLog(const base::ListValue* list) {
|
||||
const base::Value::ListStorage& params = list->GetList();
|
||||
|
||||
// Determine the capture mode.
|
||||
capture_mode_ = net::NetLogCaptureMode::Default();
|
||||
capture_mode_ = net::NetLogCaptureMode::kDefault;
|
||||
if (!params.empty() && params[0].is_string()) {
|
||||
capture_mode_ = net_log::NetExportFileWriter::CaptureModeFromString(
|
||||
params[0].GetString());
|
||||
|
@ -49,7 +49,7 @@ CastNetLog::CastNetLog() {
|
||||
if (command_line->HasSwitch(network::switches::kLogNetLog)) {
|
||||
base::FilePath log_path =
|
||||
command_line->GetSwitchValuePath(network::switches::kLogNetLog);
|
||||
net::NetLogCaptureMode capture_mode = net::NetLogCaptureMode::Default();
|
||||
net::NetLogCaptureMode capture_mode = net::NetLogCaptureMode::kDefault;
|
||||
|
||||
file_net_log_observer_ =
|
||||
net::FileNetLogObserver::CreateUnbounded(log_path, GetShellConstants());
|
||||
|
@ -632,8 +632,8 @@ void CronetURLRequestContext::NetworkTasks::StartNetLog(
|
||||
CreateNetLogEntriesForActiveObjects({context_.get()},
|
||||
net_log_file_observer_.get());
|
||||
net::NetLogCaptureMode capture_mode =
|
||||
include_socket_bytes ? net::NetLogCaptureMode::IncludeSocketBytes()
|
||||
: net::NetLogCaptureMode::Default();
|
||||
include_socket_bytes ? net::NetLogCaptureMode::kEverything
|
||||
: net::NetLogCaptureMode::kDefault;
|
||||
net_log_file_observer_->StartObserving(g_net_log.Get().net_log(),
|
||||
capture_mode);
|
||||
}
|
||||
@ -671,8 +671,8 @@ void CronetURLRequestContext::NetworkTasks::StartNetLogToBoundedFile(
|
||||
net_log_file_observer_.get());
|
||||
|
||||
net::NetLogCaptureMode capture_mode =
|
||||
include_socket_bytes ? net::NetLogCaptureMode::IncludeSocketBytes()
|
||||
: net::NetLogCaptureMode::Default();
|
||||
include_socket_bytes ? net::NetLogCaptureMode::kEverything
|
||||
: net::NetLogCaptureMode::kDefault;
|
||||
net_log_file_observer_->StartObserving(g_net_log.Get().net_log(),
|
||||
capture_mode);
|
||||
}
|
||||
|
@ -175,8 +175,8 @@ void CronetEnvironment::StartNetLogOnNetworkThread(const base::FilePath& path,
|
||||
return;
|
||||
|
||||
net::NetLogCaptureMode capture_mode =
|
||||
log_bytes ? net::NetLogCaptureMode::IncludeSocketBytes()
|
||||
: net::NetLogCaptureMode::Default();
|
||||
log_bytes ? net::NetLogCaptureMode::kEverything
|
||||
: net::NetLogCaptureMode::kDefault;
|
||||
|
||||
file_net_log_observer_ =
|
||||
net::FileNetLogObserver::CreateUnbounded(path, nullptr);
|
||||
|
@ -86,7 +86,7 @@ NetExportFileWriter::NetExportFileWriter()
|
||||
: state_(STATE_UNINITIALIZED),
|
||||
log_exists_(false),
|
||||
log_capture_mode_known_(false),
|
||||
log_capture_mode_(net::NetLogCaptureMode::Default()),
|
||||
log_capture_mode_(net::NetLogCaptureMode::kDefault),
|
||||
default_log_base_dir_getter_(base::Bind(&base::GetTempDir)),
|
||||
weak_ptr_factory_(this) {}
|
||||
|
||||
@ -294,11 +294,11 @@ void NetExportFileWriter::GetFilePathToCompletedLog(
|
||||
|
||||
std::string NetExportFileWriter::CaptureModeToString(
|
||||
net::NetLogCaptureMode capture_mode) {
|
||||
if (capture_mode == net::NetLogCaptureMode::Default())
|
||||
if (capture_mode == net::NetLogCaptureMode::kDefault)
|
||||
return "STRIP_PRIVATE_DATA";
|
||||
if (capture_mode == net::NetLogCaptureMode::IncludeCookiesAndCredentials())
|
||||
if (capture_mode == net::NetLogCaptureMode::kIncludeSensitive)
|
||||
return "NORMAL";
|
||||
if (capture_mode == net::NetLogCaptureMode::IncludeSocketBytes())
|
||||
if (capture_mode == net::NetLogCaptureMode::kEverything)
|
||||
return "LOG_BYTES";
|
||||
NOTREACHED();
|
||||
return "STRIP_PRIVATE_DATA";
|
||||
@ -307,13 +307,13 @@ std::string NetExportFileWriter::CaptureModeToString(
|
||||
net::NetLogCaptureMode NetExportFileWriter::CaptureModeFromString(
|
||||
const std::string& capture_mode_string) {
|
||||
if (capture_mode_string == "STRIP_PRIVATE_DATA")
|
||||
return net::NetLogCaptureMode::Default();
|
||||
return net::NetLogCaptureMode::kDefault;
|
||||
if (capture_mode_string == "NORMAL")
|
||||
return net::NetLogCaptureMode::IncludeCookiesAndCredentials();
|
||||
return net::NetLogCaptureMode::kIncludeSensitive;
|
||||
if (capture_mode_string == "LOG_BYTES")
|
||||
return net::NetLogCaptureMode::IncludeSocketBytes();
|
||||
return net::NetLogCaptureMode::kEverything;
|
||||
NOTREACHED();
|
||||
return net::NetLogCaptureMode::Default();
|
||||
return net::NetLogCaptureMode::kDefault;
|
||||
}
|
||||
|
||||
void NetExportFileWriter::SetDefaultLogBaseDirectoryGetterForTest(
|
||||
|
@ -48,8 +48,8 @@ base::FilePath::CharType kLogRelativePath[] =
|
||||
FILE_PATH_LITERAL("net-export/chrome-net-export-log.json");
|
||||
|
||||
const char kCaptureModeDefaultString[] = "STRIP_PRIVATE_DATA";
|
||||
const char kCaptureModeIncludeCookiesAndCredentialsString[] = "NORMAL";
|
||||
const char kCaptureModeIncludeSocketBytesString[] = "LOG_BYTES";
|
||||
const char kCaptureModeIncludeSensitiveString[] = "NORMAL";
|
||||
const char kCaptureModeIncludeEverythingString[] = "LOG_BYTES";
|
||||
|
||||
const char kStateUninitializedString[] = "UNINITIALIZED";
|
||||
const char kStateInitializingString[] = "INITIALIZING";
|
||||
@ -499,13 +499,13 @@ TEST_F(NetExportFileWriterTest, InitWithExistingLog) {
|
||||
|
||||
TEST_F(NetExportFileWriterTest, StartAndStopWithAllCaptureModes) {
|
||||
const net::NetLogCaptureMode capture_modes[3] = {
|
||||
net::NetLogCaptureMode::Default(),
|
||||
net::NetLogCaptureMode::IncludeCookiesAndCredentials(),
|
||||
net::NetLogCaptureMode::IncludeSocketBytes()};
|
||||
net::NetLogCaptureMode::kDefault,
|
||||
net::NetLogCaptureMode::kIncludeSensitive,
|
||||
net::NetLogCaptureMode::kEverything};
|
||||
|
||||
const std::string capture_mode_strings[3] = {
|
||||
kCaptureModeDefaultString, kCaptureModeIncludeCookiesAndCredentialsString,
|
||||
kCaptureModeIncludeSocketBytesString};
|
||||
kCaptureModeDefaultString, kCaptureModeIncludeSensitiveString,
|
||||
kCaptureModeIncludeEverythingString};
|
||||
|
||||
ASSERT_TRUE(InitializeThenVerifyNewState(true, false));
|
||||
|
||||
@ -555,7 +555,7 @@ TEST_F(NetExportFileWriterTest, StartClearsFile) {
|
||||
ASSERT_TRUE(InitializeThenVerifyNewState(true, false));
|
||||
|
||||
ASSERT_TRUE(StartThenVerifyNewState(
|
||||
base::FilePath(), net::NetLogCaptureMode::Default(),
|
||||
base::FilePath(), net::NetLogCaptureMode::kDefault,
|
||||
kCaptureModeDefaultString, network_context()));
|
||||
|
||||
ASSERT_TRUE(StopThenVerifyNewStateAndFile(base::FilePath(), nullptr,
|
||||
@ -576,7 +576,7 @@ TEST_F(NetExportFileWriterTest, StartClearsFile) {
|
||||
// Start and stop again and make sure the file is back to the size it was
|
||||
// before adding the junk data.
|
||||
ASSERT_TRUE(StartThenVerifyNewState(
|
||||
base::FilePath(), net::NetLogCaptureMode::Default(),
|
||||
base::FilePath(), net::NetLogCaptureMode::kDefault,
|
||||
kCaptureModeDefaultString, network_context()));
|
||||
|
||||
ASSERT_TRUE(StopThenVerifyNewStateAndFile(base::FilePath(), nullptr,
|
||||
@ -594,7 +594,7 @@ TEST_F(NetExportFileWriterTest, AddEvent) {
|
||||
ASSERT_TRUE(InitializeThenVerifyNewState(true, false));
|
||||
|
||||
ASSERT_TRUE(StartThenVerifyNewState(
|
||||
base::FilePath(), net::NetLogCaptureMode::Default(),
|
||||
base::FilePath(), net::NetLogCaptureMode::kDefault,
|
||||
kCaptureModeDefaultString, network_context()));
|
||||
|
||||
ASSERT_TRUE(StopThenVerifyNewStateAndFile(base::FilePath(), nullptr,
|
||||
@ -605,7 +605,7 @@ TEST_F(NetExportFileWriterTest, AddEvent) {
|
||||
EXPECT_TRUE(base::GetFileSize(default_log_path(), &stop_file_size));
|
||||
|
||||
ASSERT_TRUE(StartThenVerifyNewState(
|
||||
base::FilePath(), net::NetLogCaptureMode::Default(),
|
||||
base::FilePath(), net::NetLogCaptureMode::kDefault,
|
||||
kCaptureModeDefaultString, network_context()));
|
||||
|
||||
net_log()->AddGlobalEntry(net::NetLogEventType::CANCELLED);
|
||||
@ -631,9 +631,9 @@ TEST_F(NetExportFileWriterTest, AddEventCustomPath) {
|
||||
EXPECT_TRUE(
|
||||
base::CreateDirectoryAndGetError(custom_log_path.DirName(), nullptr));
|
||||
|
||||
ASSERT_TRUE(StartThenVerifyNewState(
|
||||
custom_log_path, net::NetLogCaptureMode::Default(),
|
||||
kCaptureModeDefaultString, network_context()));
|
||||
ASSERT_TRUE(
|
||||
StartThenVerifyNewState(custom_log_path, net::NetLogCaptureMode::kDefault,
|
||||
kCaptureModeDefaultString, network_context()));
|
||||
|
||||
ASSERT_TRUE(StopThenVerifyNewStateAndFile(custom_log_path, nullptr,
|
||||
kCaptureModeDefaultString));
|
||||
@ -642,9 +642,9 @@ TEST_F(NetExportFileWriterTest, AddEventCustomPath) {
|
||||
int64_t stop_file_size;
|
||||
EXPECT_TRUE(base::GetFileSize(custom_log_path, &stop_file_size));
|
||||
|
||||
ASSERT_TRUE(StartThenVerifyNewState(
|
||||
custom_log_path, net::NetLogCaptureMode::Default(),
|
||||
kCaptureModeDefaultString, network_context()));
|
||||
ASSERT_TRUE(
|
||||
StartThenVerifyNewState(custom_log_path, net::NetLogCaptureMode::kDefault,
|
||||
kCaptureModeDefaultString, network_context()));
|
||||
|
||||
net_log()->AddGlobalEntry(net::NetLogEventType::CANCELLED);
|
||||
|
||||
@ -668,7 +668,7 @@ TEST_F(NetExportFileWriterTest, StopWithPolledData) {
|
||||
dummy_polled_data->SetString(kDummyPolledDataPath, kDummyPolledDataString);
|
||||
|
||||
ASSERT_TRUE(StartThenVerifyNewState(
|
||||
base::FilePath(), net::NetLogCaptureMode::Default(),
|
||||
base::FilePath(), net::NetLogCaptureMode::kDefault,
|
||||
kCaptureModeDefaultString, network_context()));
|
||||
|
||||
ASSERT_TRUE(StopThenVerifyNewStateAndFile(base::FilePath(),
|
||||
@ -753,7 +753,7 @@ TEST_F(NetExportFileWriterTest, StartWithNetworkContextActive) {
|
||||
// thing since the post-redirect URL will get blocked by the custom handler.
|
||||
run_loop.Run();
|
||||
ASSERT_TRUE(StartThenVerifyNewState(
|
||||
base::FilePath(), net::NetLogCaptureMode::Default(),
|
||||
base::FilePath(), net::NetLogCaptureMode::kDefault,
|
||||
kCaptureModeDefaultString, network_context()));
|
||||
|
||||
ASSERT_TRUE(StopThenVerifyNewStateAndFile(base::FilePath(), nullptr,
|
||||
@ -789,9 +789,9 @@ TEST_F(NetExportFileWriterTest, ReceiveStartWhileInitializing) {
|
||||
// process from completing, so this ensures that StartNetLog() is received
|
||||
// before |file_writer_| finishes initialization, which means this
|
||||
// should be a no-op.
|
||||
file_writer()->StartNetLog(
|
||||
base::FilePath(), net::NetLogCaptureMode::Default(), kMaxLogSizeBytes,
|
||||
base::CommandLine::StringType(), kChannelString, network_context());
|
||||
file_writer()->StartNetLog(base::FilePath(), net::NetLogCaptureMode::kDefault,
|
||||
kMaxLogSizeBytes, base::CommandLine::StringType(),
|
||||
kChannelString, network_context());
|
||||
|
||||
// Now run the main message loop. Make sure StartNetLog() was ignored by
|
||||
// checking that the next two states are "initializing" followed by
|
||||
@ -809,8 +809,8 @@ TEST_F(NetExportFileWriterTest, ReceiveStartWhileStoppingLog) {
|
||||
|
||||
// Call StartNetLog() on |file_writer_| and wait for the state change.
|
||||
ASSERT_TRUE(StartThenVerifyNewState(
|
||||
base::FilePath(), net::NetLogCaptureMode::IncludeSocketBytes(),
|
||||
kCaptureModeIncludeSocketBytesString, network_context()));
|
||||
base::FilePath(), net::NetLogCaptureMode::kEverything,
|
||||
kCaptureModeIncludeEverythingString, network_context()));
|
||||
|
||||
// Tell |file_writer_| to stop logging.
|
||||
file_writer()->StopNetLog(nullptr);
|
||||
@ -820,9 +820,9 @@ TEST_F(NetExportFileWriterTest, ReceiveStartWhileStoppingLog) {
|
||||
// from completing, so this ensures StartNetLog() is received before
|
||||
// |file_writer_| finishes stopping, which means this should be a
|
||||
// no-op.
|
||||
file_writer()->StartNetLog(
|
||||
base::FilePath(), net::NetLogCaptureMode::Default(), kMaxLogSizeBytes,
|
||||
base::CommandLine::StringType(), kChannelString, network_context());
|
||||
file_writer()->StartNetLog(base::FilePath(), net::NetLogCaptureMode::kDefault,
|
||||
kMaxLogSizeBytes, base::CommandLine::StringType(),
|
||||
kChannelString, network_context());
|
||||
|
||||
// Now run the main message loop. Make sure the last StartNetLog() was
|
||||
// ignored by checking that the next two states are "stopping-log" followed by
|
||||
@ -833,7 +833,7 @@ TEST_F(NetExportFileWriterTest, ReceiveStartWhileStoppingLog) {
|
||||
ASSERT_TRUE(VerifyState(std::move(state), kStateStoppingLogString));
|
||||
state = test_state_observer()->WaitForNewState();
|
||||
ASSERT_TRUE(VerifyState(std::move(state), kStateNotLoggingString, true, true,
|
||||
kCaptureModeIncludeSocketBytesString));
|
||||
kCaptureModeIncludeEverythingString));
|
||||
}
|
||||
|
||||
TEST_F(NetExportFileWriterTest, HandleCrash) {
|
||||
@ -841,8 +841,8 @@ TEST_F(NetExportFileWriterTest, HandleCrash) {
|
||||
|
||||
ASSERT_TRUE(InitializeThenVerifyNewState(true, false));
|
||||
ASSERT_TRUE(StartThenVerifyNewState(
|
||||
base::FilePath(), net::NetLogCaptureMode::IncludeSocketBytes(),
|
||||
kCaptureModeIncludeSocketBytesString, &fake_network_context));
|
||||
base::FilePath(), net::NetLogCaptureMode::kEverything,
|
||||
kCaptureModeIncludeEverythingString, &fake_network_context));
|
||||
|
||||
// Break the pipe, as if network service crashed.
|
||||
fake_network_context.Disconnect();
|
||||
|
@ -128,16 +128,28 @@ net::NetLogCaptureMode GetNetCaptureModeFromCommandLine(
|
||||
std::string value = command_line.GetSwitchValueASCII(switch_name);
|
||||
|
||||
if (value == "Default")
|
||||
return net::NetLogCaptureMode::Default();
|
||||
if (value == "IncludeCookiesAndCredentials")
|
||||
return net::NetLogCaptureMode::IncludeCookiesAndCredentials();
|
||||
if (value == "IncludeSocketBytes")
|
||||
return net::NetLogCaptureMode::IncludeSocketBytes();
|
||||
return net::NetLogCaptureMode::kDefault;
|
||||
if (value == "IncludeSensitive")
|
||||
return net::NetLogCaptureMode::kIncludeSensitive;
|
||||
if (value == "Everything")
|
||||
return net::NetLogCaptureMode::kEverything;
|
||||
|
||||
// Warn when using the old command line switches.
|
||||
if (value == "IncludeCookiesAndCredentials") {
|
||||
LOG(ERROR) << "Deprecated value for --" << switch_name
|
||||
<< ". Use IncludeSensitive instead";
|
||||
return net::NetLogCaptureMode::kIncludeSensitive;
|
||||
}
|
||||
if (value == "IncludeSocketBytes") {
|
||||
LOG(ERROR) << "Deprecated value for --" << switch_name
|
||||
<< ". Use Everything instead";
|
||||
return net::NetLogCaptureMode::kEverything;
|
||||
}
|
||||
|
||||
LOG(ERROR) << "Unrecognized value for --" << switch_name;
|
||||
}
|
||||
|
||||
return net::NetLogCaptureMode::Default();
|
||||
return net::NetLogCaptureMode::kDefault;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -37,7 +37,7 @@ std::unique_ptr<base::DictionaryValue> GetWebEngineConstants() {
|
||||
|
||||
WebEngineNetLog::WebEngineNetLog(const base::FilePath& log_path) {
|
||||
if (!log_path.empty()) {
|
||||
net::NetLogCaptureMode capture_mode = net::NetLogCaptureMode::Default();
|
||||
net::NetLogCaptureMode capture_mode = net::NetLogCaptureMode::kDefault;
|
||||
file_net_log_observer_ = net::FileNetLogObserver::CreateUnbounded(
|
||||
log_path, GetWebEngineConstants());
|
||||
file_net_log_observer_->StartObserving(this, capture_mode);
|
||||
|
@ -335,7 +335,7 @@ void MCSProbe::InitializeNetworkState() {
|
||||
base::FilePath log_path = command_line_.GetSwitchValuePath(kLogFileSwitch);
|
||||
logger_ = net::FileNetLogObserver::CreateUnbounded(log_path, nullptr);
|
||||
net::NetLogCaptureMode capture_mode =
|
||||
net::NetLogCaptureMode::IncludeCookiesAndCredentials();
|
||||
net::NetLogCaptureMode::kIncludeSensitive;
|
||||
logger_->StartObserving(&net_log_, capture_mode);
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ void NetExportMessageHandler::OnStartNetLog(const base::ListValue* list) {
|
||||
const base::Value::ListStorage& params = list->GetList();
|
||||
|
||||
// Determine the capture mode.
|
||||
net::NetLogCaptureMode capture_mode = net::NetLogCaptureMode::Default();
|
||||
net::NetLogCaptureMode capture_mode = net::NetLogCaptureMode::kDefault;
|
||||
if (params.size() > 0 && params[0].is_string()) {
|
||||
capture_mode = net_log::NetExportFileWriter::CaptureModeFromString(
|
||||
params[0].GetString());
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "net/cert/signed_certificate_timestamp_and_status.h"
|
||||
#include "net/log/net_log_capture_mode.h"
|
||||
|
||||
namespace base {
|
||||
class Value;
|
||||
@ -16,8 +17,6 @@ class Value;
|
||||
|
||||
namespace net {
|
||||
|
||||
class NetLogCaptureMode;
|
||||
|
||||
// Creates a dictionary of processed Signed Certificate Timestamps to be
|
||||
// logged in the NetLog.
|
||||
// See the documentation for SIGNED_CERTIFICATE_TIMESTAMPS_CHECKED
|
||||
|
@ -35,8 +35,6 @@
|
||||
|
||||
namespace net {
|
||||
|
||||
class NetLogCaptureMode;
|
||||
|
||||
// Allows DoVerifyOnWorkerThread to wait on a base::WaitableEvent.
|
||||
// DoVerifyOnWorkerThread may wait on network operations done on a separate
|
||||
// sequence. For instance when using the NSS-based implementation of certificate
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "net/base/net_export.h"
|
||||
#include "net/log/net_log_capture_mode.h"
|
||||
|
||||
namespace base {
|
||||
class Value;
|
||||
@ -15,7 +16,6 @@ class Value;
|
||||
|
||||
namespace net {
|
||||
|
||||
class NetLogCaptureMode;
|
||||
class X509Certificate;
|
||||
|
||||
// Creates NetLog parameter to describe an X509Certificate.
|
||||
|
@ -20,7 +20,7 @@ base::Value NetLogCookieMonsterConstructorCallback(
|
||||
base::Value NetLogCookieMonsterCookieAdded(const CanonicalCookie* cookie,
|
||||
bool sync_requested,
|
||||
NetLogCaptureMode capture_mode) {
|
||||
if (!capture_mode.include_cookies_and_credentials())
|
||||
if (!NetLogCaptureIncludesSensitive(capture_mode))
|
||||
return base::Value();
|
||||
|
||||
base::Value dict(base::Value::Type::DICTIONARY);
|
||||
@ -41,7 +41,7 @@ base::Value NetLogCookieMonsterCookieDeleted(const CanonicalCookie* cookie,
|
||||
CookieChangeCause cause,
|
||||
bool sync_requested,
|
||||
NetLogCaptureMode capture_mode) {
|
||||
if (!capture_mode.include_cookies_and_credentials())
|
||||
if (!NetLogCaptureIncludesSensitive(capture_mode))
|
||||
return base::Value();
|
||||
|
||||
base::Value dict(base::Value::Type::DICTIONARY);
|
||||
@ -59,7 +59,7 @@ base::Value NetLogCookieMonsterCookieRejectedSecure(
|
||||
const CanonicalCookie* old_cookie,
|
||||
const CanonicalCookie* new_cookie,
|
||||
NetLogCaptureMode capture_mode) {
|
||||
if (!capture_mode.include_cookies_and_credentials())
|
||||
if (!NetLogCaptureIncludesSensitive(capture_mode))
|
||||
return base::Value();
|
||||
base::Value dict(base::Value::Type::DICTIONARY);
|
||||
dict.SetStringKey("name", old_cookie->Name());
|
||||
@ -75,7 +75,7 @@ base::Value NetLogCookieMonsterCookieRejectedHttponly(
|
||||
const CanonicalCookie* old_cookie,
|
||||
const CanonicalCookie* new_cookie,
|
||||
NetLogCaptureMode capture_mode) {
|
||||
if (!capture_mode.include_cookies_and_credentials())
|
||||
if (!NetLogCaptureIncludesSensitive(capture_mode))
|
||||
return base::Value();
|
||||
base::Value dict(base::Value::Type::DICTIONARY);
|
||||
dict.SetStringKey("name", old_cookie->Name());
|
||||
@ -91,7 +91,7 @@ base::Value NetLogCookieMonsterCookiePreservedSkippedSecure(
|
||||
const CanonicalCookie* preserved,
|
||||
const CanonicalCookie* new_cookie,
|
||||
NetLogCaptureMode capture_mode) {
|
||||
if (!capture_mode.include_cookies_and_credentials())
|
||||
if (!NetLogCaptureIncludesSensitive(capture_mode))
|
||||
return base::Value();
|
||||
base::Value dict(base::Value::Type::DICTIONARY);
|
||||
dict.SetStringKey("name", preserved->Name());
|
||||
|
@ -1946,8 +1946,7 @@ TEST_F(DnsTransactionTest, HttpsPostLookupWithLog) {
|
||||
TransactionHelper helper0(kT0HostName, kT0Qtype, true /* secure */,
|
||||
kT0RecordCount);
|
||||
CountingObserver observer;
|
||||
helper0.net_log()->AddObserver(&observer,
|
||||
NetLogCaptureMode::IncludeSocketBytes());
|
||||
helper0.net_log()->AddObserver(&observer, NetLogCaptureMode::kEverything);
|
||||
EXPECT_TRUE(helper0.RunUntilDone(transaction_factory_.get()));
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(observer.count(), 5);
|
||||
|
@ -47,7 +47,7 @@ namespace {
|
||||
|
||||
base::Value CookieKeyedLoadNetLogCallback(const std::string& key,
|
||||
net::NetLogCaptureMode capture_mode) {
|
||||
if (!capture_mode.include_cookies_and_credentials())
|
||||
if (!net::NetLogCaptureIncludesSensitive(capture_mode))
|
||||
return base::Value();
|
||||
base::DictionaryValue dict;
|
||||
dict.SetString("key", key);
|
||||
|
@ -392,7 +392,7 @@ TEST_F(SQLitePersistentCookieStoreTest, TestLoadCookiesForKey) {
|
||||
base::Unretained(this)),
|
||||
net_log.bound());
|
||||
base::RunLoop run_loop;
|
||||
net_log.SetCaptureMode(NetLogCaptureMode::Default());
|
||||
net_log.SetCaptureMode(NetLogCaptureMode::kDefault);
|
||||
store_->LoadCookiesForKey(
|
||||
"aaa.com", base::Bind(&SQLitePersistentCookieStoreTest::OnKeyLoaded,
|
||||
base::Unretained(this), run_loop.QuitClosure()));
|
||||
|
@ -408,7 +408,7 @@ class BidirectionalStreamTest : public TestWithScopedTaskEnvironment {
|
||||
ssl_data_.next_proto = kProtoHTTP2;
|
||||
ssl_data_.ssl_info.cert =
|
||||
ImportCertFromFile(GetTestCertsDirectory(), "ok_cert.pem");
|
||||
net_log_.SetCaptureMode(NetLogCaptureMode::IncludeSocketBytes());
|
||||
net_log_.SetCaptureMode(NetLogCaptureMode::kEverything);
|
||||
socket_factory_ = new MockTaggingClientSocketFactory();
|
||||
session_deps_.socket_factory.reset(socket_factory_);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ base::Value NetLogParameterChannelBindings(
|
||||
const std::string& channel_binding_token,
|
||||
NetLogCaptureMode capture_mode) {
|
||||
base::DictionaryValue dict;
|
||||
if (!capture_mode.include_socket_bytes())
|
||||
if (!NetLogCaptureIncludesSocketBytes(capture_mode))
|
||||
return std::move(dict);
|
||||
|
||||
dict.Clear();
|
||||
|
@ -41,7 +41,7 @@ std::string ElideHeaderValueForNetLog(NetLogCaptureMode capture_mode,
|
||||
std::string::const_iterator redact_end = value.begin();
|
||||
|
||||
if (redact_begin == redact_end &&
|
||||
!capture_mode.include_cookies_and_credentials()) {
|
||||
!NetLogCaptureIncludesSensitive(capture_mode)) {
|
||||
if (base::EqualsCaseInsensitiveASCII(header, "set-cookie") ||
|
||||
base::EqualsCaseInsensitiveASCII(header, "set-cookie2") ||
|
||||
base::EqualsCaseInsensitiveASCII(header, "cookie") ||
|
||||
|
@ -11,61 +11,61 @@ namespace net {
|
||||
TEST(HttpLogUtilTest, ElideHeaderValueForNetLog) {
|
||||
// Only elide for appropriate log level.
|
||||
EXPECT_EQ("[10 bytes were stripped]",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::Default(), "Cookie",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::kDefault, "Cookie",
|
||||
"name=value"));
|
||||
EXPECT_EQ("name=value", ElideHeaderValueForNetLog(
|
||||
NetLogCaptureMode::IncludeCookiesAndCredentials(),
|
||||
"Cookie", "name=value"));
|
||||
EXPECT_EQ("name=value",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::kIncludeSensitive,
|
||||
"Cookie", "name=value"));
|
||||
|
||||
// Headers are compared case insensitively.
|
||||
EXPECT_EQ("[10 bytes were stripped]",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::Default(), "cOoKiE",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::kDefault, "cOoKiE",
|
||||
"name=value"));
|
||||
|
||||
// These headers should be completely elided.
|
||||
EXPECT_EQ("[10 bytes were stripped]",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
|
||||
"Set-Cookie", "name=value"));
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::kDefault, "Set-Cookie",
|
||||
"name=value"));
|
||||
EXPECT_EQ("[10 bytes were stripped]",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::kDefault,
|
||||
"Set-Cookie2", "name=value"));
|
||||
EXPECT_EQ("[10 bytes were stripped]",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::kDefault,
|
||||
"Authorization", "Basic 1234"));
|
||||
EXPECT_EQ("[10 bytes were stripped]",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::kDefault,
|
||||
"Proxy-Authorization", "Basic 1234"));
|
||||
|
||||
// Unknown headers should pass through.
|
||||
EXPECT_EQ("value", ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
|
||||
EXPECT_EQ("value", ElideHeaderValueForNetLog(NetLogCaptureMode::kDefault,
|
||||
"Boring", "value"));
|
||||
|
||||
// Basic and Digest auth challenges are public.
|
||||
EXPECT_EQ("Basic realm=test",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::kDefault,
|
||||
"WWW-Authenticate", "Basic realm=test"));
|
||||
EXPECT_EQ("Digest realm=test",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::kDefault,
|
||||
"WWW-Authenticate", "Digest realm=test"));
|
||||
EXPECT_EQ("Basic realm=test", ElideHeaderValueForNetLog(
|
||||
NetLogCaptureMode::Default(),
|
||||
NetLogCaptureMode::kDefault,
|
||||
"Proxy-Authenticate", "Basic realm=test"));
|
||||
EXPECT_EQ(
|
||||
"Digest realm=test",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::kDefault,
|
||||
"Proxy-Authenticate", "Digest realm=test"));
|
||||
|
||||
// Multi-round mechanisms partially elided.
|
||||
EXPECT_EQ("NTLM [4 bytes were stripped]",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::kDefault,
|
||||
"WWW-Authenticate", "NTLM 1234"));
|
||||
EXPECT_EQ("NTLM [4 bytes were stripped]",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::kDefault,
|
||||
"Proxy-Authenticate", "NTLM 1234"));
|
||||
|
||||
// Leave whitespace intact.
|
||||
EXPECT_EQ("NTLM [4 bytes were stripped] ",
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
|
||||
ElideHeaderValueForNetLog(NetLogCaptureMode::kDefault,
|
||||
"WWW-Authenticate", "NTLM 1234 "));
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "net/base/net_export.h"
|
||||
#include "net/log/net_log_capture_mode.h"
|
||||
|
||||
namespace base {
|
||||
class Value;
|
||||
@ -24,8 +25,6 @@ class Value;
|
||||
|
||||
namespace net {
|
||||
|
||||
class NetLogCaptureMode;
|
||||
|
||||
class NET_EXPORT HttpRequestHeaders {
|
||||
public:
|
||||
struct NET_EXPORT HeaderKeyValuePair {
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "base/time/time.h"
|
||||
#include "net/base/net_export.h"
|
||||
#include "net/http/http_version.h"
|
||||
#include "net/log/net_log_capture_mode.h"
|
||||
|
||||
namespace base {
|
||||
class Pickle;
|
||||
@ -30,7 +31,6 @@ class Value;
|
||||
namespace net {
|
||||
|
||||
class HttpByteRange;
|
||||
class NetLogCaptureMode;
|
||||
|
||||
enum ValidationType {
|
||||
VALIDATION_NONE, // The resource is fresh.
|
||||
|
@ -23,8 +23,6 @@ class SequencedTaskRunner;
|
||||
|
||||
namespace net {
|
||||
|
||||
class NetLogCaptureMode;
|
||||
|
||||
// FileNetLogObserver watches the NetLog event stream and sends all entries to
|
||||
// a file.
|
||||
//
|
||||
|
@ -62,8 +62,7 @@ void AddEntries(FileNetLogObserver* logger,
|
||||
NetLogEntryData base_entry_data(NetLogEventType::PAC_JAVASCRIPT_ERROR, source,
|
||||
NetLogEventPhase::BEGIN,
|
||||
base::TimeTicks::Now(), &callback);
|
||||
NetLogEntry base_entry(&base_entry_data,
|
||||
NetLogCaptureMode::IncludeSocketBytes());
|
||||
NetLogEntry base_entry(&base_entry_data, NetLogCaptureMode::kEverything);
|
||||
base::Value value = base_entry.ToValue();
|
||||
std::string json;
|
||||
base::JSONWriter::Write(value, &json);
|
||||
@ -93,7 +92,7 @@ void AddEntries(FileNetLogObserver* logger,
|
||||
NetLogEntryData entry_data(NetLogEventType::PAC_JAVASCRIPT_ERROR, source,
|
||||
NetLogEventPhase::BEGIN, base::TimeTicks::Now(),
|
||||
&callback);
|
||||
NetLogEntry entry(&entry_data, NetLogCaptureMode::IncludeSocketBytes());
|
||||
NetLogEntry entry(&entry_data, NetLogCaptureMode::kEverything);
|
||||
logger->OnAddEntry(entry);
|
||||
}
|
||||
}
|
||||
@ -253,7 +252,7 @@ class FileNetLogObserverTest : public ::testing::TestWithParam<bool>,
|
||||
FileNetLogObserver::CreateUnbounded(log_path_, std::move(constants));
|
||||
}
|
||||
|
||||
logger_->StartObserving(&net_log_, NetLogCaptureMode::Default());
|
||||
logger_->StartObserving(&net_log_, NetLogCaptureMode::kDefault);
|
||||
}
|
||||
|
||||
void CreateAndStartObservingPreExisting(
|
||||
@ -275,7 +274,7 @@ class FileNetLogObserverTest : public ::testing::TestWithParam<bool>,
|
||||
std::move(file), std::move(constants));
|
||||
}
|
||||
|
||||
logger_->StartObserving(&net_log_, NetLogCaptureMode::Default());
|
||||
logger_->StartObserving(&net_log_, NetLogCaptureMode::kDefault);
|
||||
}
|
||||
|
||||
bool LogFileExists() {
|
||||
@ -314,7 +313,7 @@ class FileNetLogObserverBoundedTest : public ::testing::Test,
|
||||
int num_files) {
|
||||
logger_ = FileNetLogObserver::CreateBoundedForTests(
|
||||
log_path_, total_file_size, num_files, std::move(constants));
|
||||
logger_->StartObserving(&net_log_, NetLogCaptureMode::Default());
|
||||
logger_->StartObserving(&net_log_, NetLogCaptureMode::kDefault);
|
||||
}
|
||||
|
||||
// Returns the path for an internally directory created for bounded logs (this
|
||||
@ -500,7 +499,7 @@ TEST_P(FileNetLogObserverTest, PreExistingFileBroken) {
|
||||
else
|
||||
logger_ = FileNetLogObserver::CreateUnboundedPreExisting(std::move(file),
|
||||
nullptr);
|
||||
logger_->StartObserving(&net_log_, NetLogCaptureMode::Default());
|
||||
logger_->StartObserving(&net_log_, NetLogCaptureMode::kDefault);
|
||||
|
||||
// Send dummy event.
|
||||
AddEntries(logger_.get(), 1, kDummyEventSize);
|
||||
@ -954,7 +953,7 @@ TEST_F(FileNetLogObserverBoundedTest, PreExistingUsesSpecifiedDir) {
|
||||
|
||||
logger_ = FileNetLogObserver::CreateBoundedPreExisting(
|
||||
scratch_dir.GetPath(), std::move(file), kLargeFileSize, nullptr);
|
||||
logger_->StartObserving(&net_log_, NetLogCaptureMode::Default());
|
||||
logger_->StartObserving(&net_log_, NetLogCaptureMode::kDefault);
|
||||
|
||||
base::ThreadPoolInstance::Get()->FlushForTesting();
|
||||
EXPECT_TRUE(base::PathExists(log_path_));
|
||||
|
@ -98,7 +98,8 @@ base::Value NetLogNumberValueHelper(T num) {
|
||||
|
||||
} // namespace
|
||||
|
||||
NetLog::ThreadSafeObserver::ThreadSafeObserver() : net_log_(nullptr) {}
|
||||
NetLog::ThreadSafeObserver::ThreadSafeObserver()
|
||||
: capture_mode_(NetLogCaptureMode::kDefault), net_log_(nullptr) {}
|
||||
|
||||
NetLog::ThreadSafeObserver::~ThreadSafeObserver() {
|
||||
// Make sure we aren't watching a NetLog on destruction. Because the NetLog
|
||||
@ -180,7 +181,7 @@ void NetLog::RemoveObserver(NetLog::ThreadSafeObserver* observer) {
|
||||
observers_.erase(it);
|
||||
|
||||
observer->net_log_ = nullptr;
|
||||
observer->capture_mode_ = NetLogCaptureMode();
|
||||
observer->capture_mode_ = NetLogCaptureMode::kDefault;
|
||||
UpdateIsCapturing();
|
||||
}
|
||||
|
||||
|
@ -6,60 +6,12 @@
|
||||
|
||||
namespace net {
|
||||
|
||||
namespace {
|
||||
|
||||
// Integer representation for the capture mode. The numeric value is depended on
|
||||
// for methods of NetLogCaptureMode, which expect that higher values represent a
|
||||
// strict superset of the capabilities of lower values.
|
||||
enum InternalValue {
|
||||
// Log all events, but do not include the actual transferred bytes, and
|
||||
// remove cookies and HTTP credentials and HTTP/2 GOAWAY frame debug data.
|
||||
DEFAULT,
|
||||
|
||||
// Log all events, but do not include the actual transferred bytes as
|
||||
// parameters for bytes sent/received events.
|
||||
// TODO(bnc): Consider renaming to INCLUDE_PRIVACY_INFO.
|
||||
INCLUDE_COOKIES_AND_CREDENTIALS,
|
||||
|
||||
// Log everything possible, even if it is slow and memory expensive.
|
||||
// Includes logging of transferred bytes.
|
||||
INCLUDE_SOCKET_BYTES,
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
NetLogCaptureMode::NetLogCaptureMode() : NetLogCaptureMode(DEFAULT) {
|
||||
bool NetLogCaptureIncludesSensitive(NetLogCaptureMode capture_mode) {
|
||||
return capture_mode >= NetLogCaptureMode::kIncludeSensitive;
|
||||
}
|
||||
|
||||
NetLogCaptureMode NetLogCaptureMode::Default() {
|
||||
return NetLogCaptureMode(DEFAULT);
|
||||
}
|
||||
|
||||
NetLogCaptureMode NetLogCaptureMode::IncludeCookiesAndCredentials() {
|
||||
return NetLogCaptureMode(INCLUDE_COOKIES_AND_CREDENTIALS);
|
||||
}
|
||||
|
||||
NetLogCaptureMode NetLogCaptureMode::IncludeSocketBytes() {
|
||||
return NetLogCaptureMode(INCLUDE_SOCKET_BYTES);
|
||||
}
|
||||
|
||||
bool NetLogCaptureMode::include_cookies_and_credentials() const {
|
||||
return value_ >= INCLUDE_COOKIES_AND_CREDENTIALS;
|
||||
}
|
||||
|
||||
bool NetLogCaptureMode::include_socket_bytes() const {
|
||||
return value_ >= INCLUDE_SOCKET_BYTES;
|
||||
}
|
||||
|
||||
bool NetLogCaptureMode::operator==(NetLogCaptureMode mode) const {
|
||||
return value_ == mode.value_;
|
||||
}
|
||||
|
||||
bool NetLogCaptureMode::operator!=(NetLogCaptureMode mode) const {
|
||||
return !(*this == mode);
|
||||
}
|
||||
|
||||
NetLogCaptureMode::NetLogCaptureMode(uint32_t value) : value_(value) {
|
||||
bool NetLogCaptureIncludesSocketBytes(NetLogCaptureMode capture_mode) {
|
||||
return capture_mode == NetLogCaptureMode::kEverything;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
|
@ -11,52 +11,45 @@
|
||||
|
||||
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.
|
||||
// NetLogCaptureMode specifies the logging level.
|
||||
//
|
||||
// It is used to control which events are emitted to the log, and what level of
|
||||
// detail is included in their parameters.
|
||||
//
|
||||
// The capture mode is expressed as a number, where higher values imply more
|
||||
// information. The exact numeric values should not be depended on.
|
||||
enum class NetLogCaptureMode : uint32_t {
|
||||
// Default logging level, which is expected to be light-weight and
|
||||
// does best-effort stripping of privacy/security sensitive data.
|
||||
//
|
||||
// * Includes most HTTP request/response headers, but strips cookies and
|
||||
// auth.
|
||||
// * Does not include the full bytes read/written to sockets.
|
||||
kDefault,
|
||||
|
||||
// The default constructor creates a capture mode equivalent to
|
||||
// Default().
|
||||
NetLogCaptureMode();
|
||||
// Logging level that includes everything from kDefault, plus sensitive data
|
||||
// that it may have strippped.
|
||||
//
|
||||
// * Includes cookies and authentication headers.
|
||||
// * Does not include the full bytes read/written to sockets.
|
||||
kIncludeSensitive,
|
||||
|
||||
// Constructs a capture mode which logs basic events and event parameters.
|
||||
// include_cookies_and_credentials() --> 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.
|
||||
// include_cookies_and_credentials() --> true
|
||||
// include_socket_bytes() --> false
|
||||
// TODO(bnc): Consider renaming to IncludePrivacyInfo().
|
||||
static NetLogCaptureMode IncludeCookiesAndCredentials();
|
||||
|
||||
// Constructs a capture mode which logs the data sent/received from sockets.
|
||||
// include_cookies_and_credentials() --> true
|
||||
// include_socket_bytes() --> true
|
||||
static NetLogCaptureMode IncludeSocketBytes();
|
||||
|
||||
// If include_cookies_and_credentials() is true , then it is OK to log
|
||||
// events which contain cookies, credentials or other privacy sensitive data.
|
||||
// TODO(bnc): Consider renaming to include_privacy_info().
|
||||
bool include_cookies_and_credentials() 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;
|
||||
|
||||
bool operator==(NetLogCaptureMode mode) const;
|
||||
bool operator!=(NetLogCaptureMode mode) const;
|
||||
|
||||
private:
|
||||
explicit NetLogCaptureMode(uint32_t value);
|
||||
|
||||
int32_t value_;
|
||||
// Logging level that includes everything that is possible to be logged.
|
||||
//
|
||||
// * Includes the actual bytes read/written to sockets
|
||||
// * Will result in large log files.
|
||||
kEverything,
|
||||
};
|
||||
|
||||
// Returns true if |capture_mode| permits logging sensitive values such as
|
||||
// cookies and credentials.
|
||||
NET_EXPORT bool NetLogCaptureIncludesSensitive(NetLogCaptureMode capture_mode);
|
||||
|
||||
// Returns true if |capture_mode| permits logging the full request/response
|
||||
// bytes from sockets.
|
||||
NET_EXPORT bool NetLogCaptureIncludesSocketBytes(
|
||||
NetLogCaptureMode capture_mode);
|
||||
|
||||
} // namespace net
|
||||
|
||||
#endif // NET_LOG_NET_LOG_CAPTURE_MODE_H_
|
||||
|
@ -10,41 +10,25 @@ namespace net {
|
||||
|
||||
namespace {
|
||||
|
||||
TEST(NetLogCaptureMode, DefaultConstructor) {
|
||||
EXPECT_EQ(NetLogCaptureMode(), NetLogCaptureMode::Default());
|
||||
}
|
||||
|
||||
TEST(NetLogCaptureMode, Default) {
|
||||
NetLogCaptureMode mode = NetLogCaptureMode::Default();
|
||||
NetLogCaptureMode mode = NetLogCaptureMode::kDefault;
|
||||
|
||||
EXPECT_FALSE(mode.include_cookies_and_credentials());
|
||||
EXPECT_FALSE(mode.include_socket_bytes());
|
||||
|
||||
EXPECT_EQ(mode, NetLogCaptureMode::Default());
|
||||
EXPECT_NE(mode, NetLogCaptureMode::IncludeCookiesAndCredentials());
|
||||
EXPECT_NE(mode, NetLogCaptureMode::IncludeSocketBytes());
|
||||
EXPECT_FALSE(NetLogCaptureIncludesSensitive(mode));
|
||||
EXPECT_FALSE(NetLogCaptureIncludesSocketBytes(mode));
|
||||
}
|
||||
|
||||
TEST(NetLogCaptureMode, IncludeCookiesAndCredentials) {
|
||||
NetLogCaptureMode mode = NetLogCaptureMode::IncludeCookiesAndCredentials();
|
||||
TEST(NetLogCaptureMode, IncludeSensitive) {
|
||||
NetLogCaptureMode mode = NetLogCaptureMode::kIncludeSensitive;
|
||||
|
||||
EXPECT_TRUE(mode.include_cookies_and_credentials());
|
||||
EXPECT_FALSE(mode.include_socket_bytes());
|
||||
|
||||
EXPECT_NE(mode, NetLogCaptureMode::Default());
|
||||
EXPECT_EQ(mode, NetLogCaptureMode::IncludeCookiesAndCredentials());
|
||||
EXPECT_NE(mode, NetLogCaptureMode::IncludeSocketBytes());
|
||||
EXPECT_TRUE(NetLogCaptureIncludesSensitive(mode));
|
||||
EXPECT_FALSE(NetLogCaptureIncludesSocketBytes(mode));
|
||||
}
|
||||
|
||||
TEST(NetLogCaptureMode, IncludeSocketBytes) {
|
||||
NetLogCaptureMode mode = NetLogCaptureMode::IncludeSocketBytes();
|
||||
TEST(NetLogCaptureMode, Everything) {
|
||||
NetLogCaptureMode mode = NetLogCaptureMode::kEverything;
|
||||
|
||||
EXPECT_TRUE(mode.include_cookies_and_credentials());
|
||||
EXPECT_TRUE(mode.include_socket_bytes());
|
||||
|
||||
EXPECT_NE(mode, NetLogCaptureMode::Default());
|
||||
EXPECT_NE(mode, NetLogCaptureMode::IncludeCookiesAndCredentials());
|
||||
EXPECT_EQ(mode, NetLogCaptureMode::IncludeSocketBytes());
|
||||
EXPECT_TRUE(NetLogCaptureIncludesSensitive(mode));
|
||||
EXPECT_TRUE(NetLogCaptureIncludesSocketBytes(mode));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -33,11 +33,11 @@ const int kEvents = 100;
|
||||
// this internal value is not exposed. These tests need to serialize a
|
||||
// NetLogCaptureMode to a base::Value, so create our own private mapping.
|
||||
int CaptureModeToInt(NetLogCaptureMode capture_mode) {
|
||||
if (capture_mode == NetLogCaptureMode::Default())
|
||||
if (capture_mode == NetLogCaptureMode::kDefault)
|
||||
return 0;
|
||||
if (capture_mode == NetLogCaptureMode::IncludeCookiesAndCredentials())
|
||||
if (capture_mode == NetLogCaptureMode::kIncludeSensitive)
|
||||
return 1;
|
||||
if (capture_mode == NetLogCaptureMode::IncludeSocketBytes())
|
||||
if (capture_mode == NetLogCaptureMode::kEverything)
|
||||
return 2;
|
||||
|
||||
ADD_FAILURE() << "Unknown capture mode";
|
||||
@ -75,9 +75,9 @@ TEST(NetLogTest, Basic) {
|
||||
// Check that the correct CaptureMode is sent to NetLog Value callbacks.
|
||||
TEST(NetLogTest, CaptureModes) {
|
||||
NetLogCaptureMode kModes[] = {
|
||||
NetLogCaptureMode::Default(),
|
||||
NetLogCaptureMode::IncludeCookiesAndCredentials(),
|
||||
NetLogCaptureMode::IncludeSocketBytes(),
|
||||
NetLogCaptureMode::kDefault,
|
||||
NetLogCaptureMode::kIncludeSensitive,
|
||||
NetLogCaptureMode::kEverything,
|
||||
};
|
||||
|
||||
TestNetLog net_log;
|
||||
@ -218,17 +218,14 @@ class AddRemoveObserverTestThread : public NetLogTestThread {
|
||||
for (int i = 0; i < kEvents; ++i) {
|
||||
ASSERT_FALSE(observer_.net_log());
|
||||
|
||||
net_log_->AddObserver(&observer_,
|
||||
NetLogCaptureMode::IncludeCookiesAndCredentials());
|
||||
net_log_->AddObserver(&observer_, NetLogCaptureMode::kIncludeSensitive);
|
||||
ASSERT_EQ(net_log_, observer_.net_log());
|
||||
ASSERT_EQ(NetLogCaptureMode::IncludeCookiesAndCredentials(),
|
||||
observer_.capture_mode());
|
||||
ASSERT_EQ(NetLogCaptureMode::kIncludeSensitive, observer_.capture_mode());
|
||||
|
||||
net_log_->SetObserverCaptureMode(&observer_,
|
||||
NetLogCaptureMode::IncludeSocketBytes());
|
||||
NetLogCaptureMode::kEverything);
|
||||
ASSERT_EQ(net_log_, observer_.net_log());
|
||||
ASSERT_EQ(NetLogCaptureMode::IncludeSocketBytes(),
|
||||
observer_.capture_mode());
|
||||
ASSERT_EQ(NetLogCaptureMode::kEverything, observer_.capture_mode());
|
||||
|
||||
net_log_->RemoveObserver(&observer_);
|
||||
ASSERT_TRUE(!observer_.net_log());
|
||||
@ -268,7 +265,7 @@ TEST(NetLogTest, NetLogEventThreads) {
|
||||
// safely detach themselves on destruction.
|
||||
CountingObserver observers[3];
|
||||
for (size_t i = 0; i < base::size(observers); ++i) {
|
||||
net_log.AddObserver(&observers[i], NetLogCaptureMode::IncludeSocketBytes());
|
||||
net_log.AddObserver(&observers[i], NetLogCaptureMode::kEverything);
|
||||
}
|
||||
|
||||
// Run a bunch of threads to completion, each of which will emit events to
|
||||
@ -292,22 +289,19 @@ TEST(NetLogTest, NetLogAddRemoveObserver) {
|
||||
EXPECT_FALSE(net_log.IsCapturing());
|
||||
|
||||
// Add the observer and add an event.
|
||||
net_log.AddObserver(&observer,
|
||||
NetLogCaptureMode::IncludeCookiesAndCredentials());
|
||||
net_log.AddObserver(&observer, NetLogCaptureMode::kIncludeSensitive);
|
||||
EXPECT_TRUE(net_log.IsCapturing());
|
||||
EXPECT_EQ(&net_log, observer.net_log());
|
||||
EXPECT_EQ(NetLogCaptureMode::IncludeCookiesAndCredentials(),
|
||||
observer.capture_mode());
|
||||
EXPECT_EQ(NetLogCaptureMode::kIncludeSensitive, observer.capture_mode());
|
||||
EXPECT_TRUE(net_log.IsCapturing());
|
||||
|
||||
AddEvent(&net_log);
|
||||
EXPECT_EQ(1, observer.count());
|
||||
|
||||
// Change the observer's logging level and add an event.
|
||||
net_log.SetObserverCaptureMode(&observer,
|
||||
NetLogCaptureMode::IncludeSocketBytes());
|
||||
net_log.SetObserverCaptureMode(&observer, NetLogCaptureMode::kEverything);
|
||||
EXPECT_EQ(&net_log, observer.net_log());
|
||||
EXPECT_EQ(NetLogCaptureMode::IncludeSocketBytes(), observer.capture_mode());
|
||||
EXPECT_EQ(NetLogCaptureMode::kEverything, observer.capture_mode());
|
||||
EXPECT_TRUE(net_log.IsCapturing());
|
||||
|
||||
AddEvent(&net_log);
|
||||
@ -322,9 +316,9 @@ TEST(NetLogTest, NetLogAddRemoveObserver) {
|
||||
EXPECT_EQ(2, observer.count());
|
||||
|
||||
// Add the observer a final time, and add an event.
|
||||
net_log.AddObserver(&observer, NetLogCaptureMode::IncludeSocketBytes());
|
||||
net_log.AddObserver(&observer, NetLogCaptureMode::kEverything);
|
||||
EXPECT_EQ(&net_log, observer.net_log());
|
||||
EXPECT_EQ(NetLogCaptureMode::IncludeSocketBytes(), observer.capture_mode());
|
||||
EXPECT_EQ(NetLogCaptureMode::kEverything, observer.capture_mode());
|
||||
EXPECT_TRUE(net_log.IsCapturing());
|
||||
|
||||
AddEvent(&net_log);
|
||||
@ -337,22 +331,18 @@ TEST(NetLogTest, NetLogTwoObservers) {
|
||||
LoggingObserver observer[2];
|
||||
|
||||
// Add first observer.
|
||||
net_log.AddObserver(&observer[0],
|
||||
NetLogCaptureMode::IncludeCookiesAndCredentials());
|
||||
net_log.AddObserver(&observer[0], NetLogCaptureMode::kIncludeSensitive);
|
||||
EXPECT_EQ(&net_log, observer[0].net_log());
|
||||
EXPECT_EQ(NULL, observer[1].net_log());
|
||||
EXPECT_EQ(NetLogCaptureMode::IncludeCookiesAndCredentials(),
|
||||
observer[0].capture_mode());
|
||||
EXPECT_EQ(NetLogCaptureMode::kIncludeSensitive, observer[0].capture_mode());
|
||||
EXPECT_TRUE(net_log.IsCapturing());
|
||||
|
||||
// Add second observer observer.
|
||||
net_log.AddObserver(&observer[1], NetLogCaptureMode::IncludeSocketBytes());
|
||||
net_log.AddObserver(&observer[1], NetLogCaptureMode::kEverything);
|
||||
EXPECT_EQ(&net_log, observer[0].net_log());
|
||||
EXPECT_EQ(&net_log, observer[1].net_log());
|
||||
EXPECT_EQ(NetLogCaptureMode::IncludeCookiesAndCredentials(),
|
||||
observer[0].capture_mode());
|
||||
EXPECT_EQ(NetLogCaptureMode::IncludeSocketBytes(),
|
||||
observer[1].capture_mode());
|
||||
EXPECT_EQ(NetLogCaptureMode::kIncludeSensitive, observer[0].capture_mode());
|
||||
EXPECT_EQ(NetLogCaptureMode::kEverything, observer[1].capture_mode());
|
||||
EXPECT_TRUE(net_log.IsCapturing());
|
||||
|
||||
// Add event and make sure both observers receive it at their respective log
|
||||
@ -370,8 +360,7 @@ TEST(NetLogTest, NetLogTwoObservers) {
|
||||
net_log.RemoveObserver(&observer[1]);
|
||||
EXPECT_EQ(&net_log, observer[0].net_log());
|
||||
EXPECT_EQ(NULL, observer[1].net_log());
|
||||
EXPECT_EQ(NetLogCaptureMode::IncludeCookiesAndCredentials(),
|
||||
observer[0].capture_mode());
|
||||
EXPECT_EQ(NetLogCaptureMode::kIncludeSensitive, observer[0].capture_mode());
|
||||
EXPECT_TRUE(net_log.IsCapturing());
|
||||
|
||||
// Add event and make sure only second observer gets it.
|
||||
@ -516,7 +505,7 @@ TEST(NetLogTest, NetLogEntryToValueEmptyParams) {
|
||||
NetLogEntryData entry_data1(NetLogEventType::REQUEST_ALIVE, NetLogSource(),
|
||||
NetLogEventPhase::BEGIN, base::TimeTicks(),
|
||||
nullptr);
|
||||
NetLogEntry entry1(&entry_data1, NetLogCaptureMode::Default());
|
||||
NetLogEntry entry1(&entry_data1, NetLogCaptureMode::kDefault);
|
||||
|
||||
// NetLogEntry with a parameters callback that returns a NONE value.
|
||||
NetLogParametersCallback callback2 =
|
||||
@ -524,7 +513,7 @@ TEST(NetLogTest, NetLogEntryToValueEmptyParams) {
|
||||
NetLogEntryData entry_data2(NetLogEventType::REQUEST_ALIVE, NetLogSource(),
|
||||
NetLogEventPhase::BEGIN, base::TimeTicks(),
|
||||
&callback2);
|
||||
NetLogEntry entry2(&entry_data2, NetLogCaptureMode::Default());
|
||||
NetLogEntry entry2(&entry_data2, NetLogCaptureMode::kDefault);
|
||||
|
||||
ASSERT_FALSE(entry_data1.parameters_callback);
|
||||
ASSERT_TRUE(entry_data2.parameters_callback);
|
||||
|
@ -507,12 +507,12 @@ NET_EXPORT void CreateNetLogEntriesForActiveObjects(
|
||||
NetLogParametersCallback callback =
|
||||
base::Bind(&GetRequestStateAsValue, base::Unretained(request));
|
||||
|
||||
// Note that passing the hardcoded NetLogCaptureMode::Default() below is
|
||||
// Note that passing the hardcoded NetLogCaptureMode::kDefault below is
|
||||
// fine, since GetRequestStateAsValue() ignores the capture mode.
|
||||
NetLogEntryData entry_data(
|
||||
NetLogEventType::REQUEST_ALIVE, request->net_log().source(),
|
||||
NetLogEventPhase::BEGIN, request->creation_time(), &callback);
|
||||
NetLogEntry entry(&entry_data, NetLogCaptureMode::Default());
|
||||
NetLogEntry entry(&entry_data, NetLogCaptureMode::kDefault);
|
||||
observer->OnAddEntry(entry);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ base::Value BytesTransferredCallback(int byte_count,
|
||||
NetLogCaptureMode capture_mode) {
|
||||
base::DictionaryValue dict;
|
||||
dict.SetInteger("byte_count", byte_count);
|
||||
if (capture_mode.include_socket_bytes() && byte_count > 0)
|
||||
if (NetLogCaptureIncludesSocketBytes(capture_mode) && byte_count > 0)
|
||||
dict.SetKey("bytes", NetLogBinaryValue(bytes, byte_count));
|
||||
return std::move(dict);
|
||||
}
|
||||
|
@ -74,8 +74,7 @@ class TestNetLog::Observer : public NetLog::ThreadSafeObserver {
|
||||
};
|
||||
|
||||
TestNetLog::TestNetLog() : observer_(new Observer()) {
|
||||
AddObserver(observer_.get(),
|
||||
NetLogCaptureMode::IncludeCookiesAndCredentials());
|
||||
AddObserver(observer_.get(), NetLogCaptureMode::kIncludeSensitive);
|
||||
}
|
||||
|
||||
TestNetLog::~TestNetLog() {
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
namespace net {
|
||||
|
||||
class NetLogCaptureMode;
|
||||
struct NetLogSource;
|
||||
|
||||
// TestNetLog is NetLog subclass which records all NetLog events that occur and
|
||||
|
@ -116,7 +116,7 @@ void TraceNetLogObserver::OnTraceLogEnabled() {
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
net_log_to_watch_->AddObserver(this, NetLogCaptureMode::Default());
|
||||
net_log_to_watch_->AddObserver(this, NetLogCaptureMode::kDefault);
|
||||
}
|
||||
|
||||
void TraceNetLogObserver::OnTraceLogDisabled() {
|
||||
|
@ -32,7 +32,6 @@ namespace net {
|
||||
|
||||
class DhcpPacFileFetcher;
|
||||
class NetLog;
|
||||
class NetLogCaptureMode;
|
||||
class ProxyResolver;
|
||||
class PacFileFetcher;
|
||||
|
||||
|
@ -140,7 +140,7 @@ base::Value NetLogSSLMessageCallback(bool is_write,
|
||||
// (that's the private key which isn't sent over the wire), but it may contain
|
||||
// information on the user's identity.
|
||||
if (!is_write || type != SSL3_MT_CERTIFICATE ||
|
||||
capture_mode.include_socket_bytes()) {
|
||||
NetLogCaptureIncludesSocketBytes(capture_mode)) {
|
||||
dict.SetKey("bytes", NetLogBinaryValue(bytes, len));
|
||||
}
|
||||
|
||||
|
@ -2387,7 +2387,7 @@ TEST_P(SSLClientSocketReadTest, Read_FullLogging) {
|
||||
|
||||
TestCompletionCallback callback;
|
||||
TestNetLog log;
|
||||
log.SetCaptureMode(NetLogCaptureMode::IncludeSocketBytes());
|
||||
log.SetCaptureMode(NetLogCaptureMode::kEverything);
|
||||
std::unique_ptr<StreamSocket> transport(
|
||||
new TCPClientSocket(addr(), nullptr, &log, NetLogSource()));
|
||||
int rv = callback.GetResult(transport->Connect(callback.callback()));
|
||||
|
@ -21,7 +21,7 @@ base::Value NetLogUDPDataTranferCallback(int byte_count,
|
||||
NetLogCaptureMode capture_mode) {
|
||||
base::DictionaryValue dict;
|
||||
dict.SetInteger("byte_count", byte_count);
|
||||
if (capture_mode.include_socket_bytes())
|
||||
if (NetLogCaptureIncludesSocketBytes(capture_mode))
|
||||
dict.SetKey("bytes", NetLogBinaryValue(bytes, byte_count));
|
||||
if (address)
|
||||
dict.SetString("address", address->ToString());
|
||||
|
@ -15,7 +15,7 @@ namespace net {
|
||||
|
||||
base::Value ElideGoAwayDebugDataForNetLog(NetLogCaptureMode capture_mode,
|
||||
base::StringPiece debug_data) {
|
||||
if (capture_mode.include_cookies_and_credentials())
|
||||
if (NetLogCaptureIncludesSensitive(capture_mode))
|
||||
return NetLogStringValue(debug_data);
|
||||
|
||||
return NetLogStringValue(base::StrCat(
|
||||
|
@ -21,15 +21,13 @@ std::string ElideGoAwayDebugDataForNetLogAsString(
|
||||
TEST(SpdyLogUtilTest, ElideGoAwayDebugDataForNetLog) {
|
||||
// Only elide for appropriate log level.
|
||||
EXPECT_EQ("[6 bytes were stripped]",
|
||||
ElideGoAwayDebugDataForNetLogAsString(NetLogCaptureMode::Default(),
|
||||
ElideGoAwayDebugDataForNetLogAsString(NetLogCaptureMode::kDefault,
|
||||
"foobar"));
|
||||
EXPECT_EQ("foobar",
|
||||
EXPECT_EQ("foobar", ElideGoAwayDebugDataForNetLogAsString(
|
||||
NetLogCaptureMode::kIncludeSensitive, "foobar"));
|
||||
EXPECT_EQ("%ESCAPED:\xE2\x80\x8B %FE%FF",
|
||||
ElideGoAwayDebugDataForNetLogAsString(
|
||||
NetLogCaptureMode::IncludeCookiesAndCredentials(), "foobar"));
|
||||
EXPECT_EQ(
|
||||
"%ESCAPED:\xE2\x80\x8B %FE%FF",
|
||||
ElideGoAwayDebugDataForNetLogAsString(
|
||||
NetLogCaptureMode::IncludeCookiesAndCredentials(), "\xfe\xff\x00"));
|
||||
NetLogCaptureMode::kIncludeSensitive, "\xfe\xff\x00"));
|
||||
}
|
||||
|
||||
TEST(SpdyLogUtilTest, ElideSpdyHeaderBlockForNetLog) {
|
||||
@ -38,7 +36,7 @@ TEST(SpdyLogUtilTest, ElideSpdyHeaderBlockForNetLog) {
|
||||
headers["cookie"] = "name=value";
|
||||
|
||||
base::ListValue list =
|
||||
ElideSpdyHeaderBlockForNetLog(headers, NetLogCaptureMode::Default());
|
||||
ElideSpdyHeaderBlockForNetLog(headers, NetLogCaptureMode::kDefault);
|
||||
|
||||
ASSERT_FALSE(list.is_none());
|
||||
ASSERT_EQ(2u, list.GetList().size());
|
||||
@ -49,8 +47,8 @@ TEST(SpdyLogUtilTest, ElideSpdyHeaderBlockForNetLog) {
|
||||
ASSERT_TRUE(list.GetList()[1].is_string());
|
||||
EXPECT_EQ("cookie: [10 bytes were stripped]", list.GetList()[1].GetString());
|
||||
|
||||
list = ElideSpdyHeaderBlockForNetLog(
|
||||
headers, NetLogCaptureMode::IncludeCookiesAndCredentials());
|
||||
list = ElideSpdyHeaderBlockForNetLog(headers,
|
||||
NetLogCaptureMode::kIncludeSensitive);
|
||||
|
||||
ASSERT_FALSE(list.is_none());
|
||||
ASSERT_EQ(2u, list.GetList().size());
|
||||
@ -68,7 +66,7 @@ TEST(SpdyLogUtilTest, SpdyHeaderBlockNetLogCallback) {
|
||||
headers["cookie"] = "name=value";
|
||||
|
||||
std::unique_ptr<base::Value> dict = base::Value::ToUniquePtrValue(
|
||||
SpdyHeaderBlockNetLogCallback(&headers, NetLogCaptureMode::Default()));
|
||||
SpdyHeaderBlockNetLogCallback(&headers, NetLogCaptureMode::kDefault));
|
||||
|
||||
ASSERT_TRUE(dict);
|
||||
ASSERT_TRUE(dict->is_dict());
|
||||
@ -87,7 +85,7 @@ TEST(SpdyLogUtilTest, SpdyHeaderBlockNetLogCallback) {
|
||||
header_list->GetList()[1].GetString());
|
||||
|
||||
dict = base::Value::ToUniquePtrValue(SpdyHeaderBlockNetLogCallback(
|
||||
&headers, NetLogCaptureMode::IncludeCookiesAndCredentials()));
|
||||
&headers, NetLogCaptureMode::kIncludeSensitive));
|
||||
|
||||
ASSERT_TRUE(dict);
|
||||
ASSERT_TRUE(dict->is_dict());
|
||||
@ -113,7 +111,7 @@ TEST(SpdyLogUtilTest, ElideSpdyHeaderBlockForNetLogWithNonUTF8Characters) {
|
||||
headers["\xde\xad"] = "\xbe\xef";
|
||||
|
||||
base::ListValue list =
|
||||
ElideSpdyHeaderBlockForNetLog(headers, NetLogCaptureMode::Default());
|
||||
ElideSpdyHeaderBlockForNetLog(headers, NetLogCaptureMode::kDefault);
|
||||
|
||||
ASSERT_EQ(3u, list.GetSize());
|
||||
std::string field;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "net/base/net_export.h"
|
||||
#include "net/base/privacy_mode.h"
|
||||
#include "net/base/request_priority.h"
|
||||
#include "net/log/net_log_capture_mode.h"
|
||||
#include "net/traffic_annotation/network_traffic_annotation.h"
|
||||
|
||||
class GURL;
|
||||
@ -23,8 +24,6 @@ class Value;
|
||||
|
||||
namespace net {
|
||||
|
||||
class NetLogCaptureMode;
|
||||
|
||||
// Returns a Value containing NetLog parameters for constructing a URLRequest.
|
||||
NET_EXPORT base::Value NetLogURLRequestConstructorCallback(
|
||||
const GURL* url,
|
||||
|
@ -43,8 +43,7 @@ void VlogNetLog::Observer::OnAddEntry(const net::NetLogEntry& entry) {
|
||||
|
||||
VlogNetLog::VlogNetLog()
|
||||
: observer_(new Observer()) {
|
||||
AddObserver(observer_.get(),
|
||||
net::NetLogCaptureMode::IncludeCookiesAndCredentials());
|
||||
AddObserver(observer_.get(), net::NetLogCaptureMode::kIncludeSensitive);
|
||||
}
|
||||
|
||||
VlogNetLog::~VlogNetLog() {
|
||||
|
@ -2479,7 +2479,7 @@ TEST_F(NetworkContextTest, CreateNetLogExporter) {
|
||||
|
||||
net::TestCompletionCallback start_callback;
|
||||
net_log_exporter->Start(std::move(out_file), std::move(dict_start),
|
||||
net::NetLogCaptureMode::Default(), 100 * 1024,
|
||||
net::NetLogCaptureMode::kDefault, 100 * 1024,
|
||||
start_callback.callback());
|
||||
EXPECT_EQ(net::OK, start_callback.WaitForResult());
|
||||
|
||||
@ -2524,7 +2524,7 @@ TEST_F(NetworkContextTest, CreateNetLogExporterUnbounded) {
|
||||
net::TestCompletionCallback start_callback;
|
||||
net_log_exporter->Start(
|
||||
std::move(out_file), base::Value(base::Value::Type::DICTIONARY),
|
||||
net::NetLogCaptureMode::Default(),
|
||||
net::NetLogCaptureMode::kDefault,
|
||||
mojom::NetLogExporter::kUnlimitedFileSize, start_callback.callback());
|
||||
EXPECT_EQ(net::OK, start_callback.WaitForResult());
|
||||
|
||||
@ -2566,7 +2566,7 @@ TEST_F(NetworkContextTest, CreateNetLogExporterErrors) {
|
||||
net::TestCompletionCallback start_callback;
|
||||
net_log_exporter->Start(
|
||||
std::move(temp_file), base::Value(base::Value::Type::DICTIONARY),
|
||||
net::NetLogCaptureMode::Default(), 100 * 1024, start_callback.callback());
|
||||
net::NetLogCaptureMode::kDefault, 100 * 1024, start_callback.callback());
|
||||
EXPECT_EQ(net::OK, start_callback.WaitForResult());
|
||||
|
||||
// Can't start twice.
|
||||
@ -2577,10 +2577,9 @@ TEST_F(NetworkContextTest, CreateNetLogExporterErrors) {
|
||||
ASSERT_TRUE(temp_file2.IsValid());
|
||||
|
||||
net::TestCompletionCallback start_callback2;
|
||||
net_log_exporter->Start(std::move(temp_file2),
|
||||
base::Value(base::Value::Type::DICTIONARY),
|
||||
net::NetLogCaptureMode::Default(), 100 * 1024,
|
||||
start_callback2.callback());
|
||||
net_log_exporter->Start(
|
||||
std::move(temp_file2), base::Value(base::Value::Type::DICTIONARY),
|
||||
net::NetLogCaptureMode::kDefault, 100 * 1024, start_callback2.callback());
|
||||
EXPECT_EQ(net::ERR_UNEXPECTED, start_callback2.WaitForResult());
|
||||
|
||||
base::DeleteFile(temp_path, false);
|
||||
@ -2624,7 +2623,7 @@ TEST_F(NetworkContextTest, DestroyNetLogExporterWhileCreatingScratchDir) {
|
||||
|
||||
net_log_exporter->Start(
|
||||
std::move(temp_file), base::Value(base::Value::Type::DICTIONARY),
|
||||
net::NetLogCaptureMode::Default(), 100, base::BindOnce([](int) {}));
|
||||
net::NetLogCaptureMode::kDefault, 100, base::BindOnce([](int) {}));
|
||||
net_log_exporter = nullptr;
|
||||
block_mktemp.Signal();
|
||||
|
||||
@ -3992,7 +3991,7 @@ TEST_F(NetworkContextTest, ForceReloadProxyConfig) {
|
||||
net_log_exporter->Start(
|
||||
std::move(net_log_file),
|
||||
/*extra_constants=*/base::Value(base::Value::Type::DICTIONARY),
|
||||
net::NetLogCaptureMode::Default(),
|
||||
net::NetLogCaptureMode::kDefault,
|
||||
network::mojom::NetLogExporter::kUnlimitedFileSize, start_callback);
|
||||
run_loop.Run();
|
||||
EXPECT_EQ(net::OK, start_param);
|
||||
|
@ -734,7 +734,7 @@ TEST_F(NetworkServiceTestWithService, StartsNetLog) {
|
||||
base::File log_file(log_path,
|
||||
base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
|
||||
network_service_->StartNetLog(
|
||||
std::move(log_file), net::NetLogCaptureMode::Default(), std::move(dict));
|
||||
std::move(log_file), net::NetLogCaptureMode::kDefault, std::move(dict));
|
||||
CreateNetworkContext();
|
||||
LoadURL(test_server()->GetURL("/echo"));
|
||||
EXPECT_EQ(net::OK, client()->completion_status().error_code);
|
||||
|
@ -12,13 +12,13 @@ bool EnumTraits<network::mojom::NetLogCaptureMode, net::NetLogCaptureMode>::
|
||||
net::NetLogCaptureMode* out) {
|
||||
switch (capture_mode) {
|
||||
case network::mojom::NetLogCaptureMode::DEFAULT:
|
||||
*out = net::NetLogCaptureMode::Default();
|
||||
*out = net::NetLogCaptureMode::kDefault;
|
||||
return true;
|
||||
case network::mojom::NetLogCaptureMode::INCLUDE_COOKIES_AND_CREDENTIALS:
|
||||
*out = net::NetLogCaptureMode::IncludeCookiesAndCredentials();
|
||||
case network::mojom::NetLogCaptureMode::INCLUDE_PRIVACY_INFO:
|
||||
*out = net::NetLogCaptureMode::kIncludeSensitive;
|
||||
return true;
|
||||
case network::mojom::NetLogCaptureMode::INCLUDE_SOCKET_BYTES:
|
||||
*out = net::NetLogCaptureMode::IncludeSocketBytes();
|
||||
case network::mojom::NetLogCaptureMode::EVERYTHING:
|
||||
*out = net::NetLogCaptureMode::kEverything;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -28,12 +28,16 @@ bool EnumTraits<network::mojom::NetLogCaptureMode, net::NetLogCaptureMode>::
|
||||
network::mojom::NetLogCaptureMode
|
||||
EnumTraits<network::mojom::NetLogCaptureMode, net::NetLogCaptureMode>::ToMojom(
|
||||
net::NetLogCaptureMode capture_mode) {
|
||||
if (capture_mode.include_cookies_and_credentials())
|
||||
return network::mojom::NetLogCaptureMode::INCLUDE_COOKIES_AND_CREDENTIALS;
|
||||
if (capture_mode.include_socket_bytes())
|
||||
return network::mojom::NetLogCaptureMode::INCLUDE_SOCKET_BYTES;
|
||||
switch (capture_mode) {
|
||||
case net::NetLogCaptureMode::kDefault:
|
||||
return network::mojom::NetLogCaptureMode::DEFAULT;
|
||||
case net::NetLogCaptureMode::kIncludeSensitive:
|
||||
return network::mojom::NetLogCaptureMode::INCLUDE_PRIVACY_INFO;
|
||||
case net::NetLogCaptureMode::kEverything:
|
||||
return network::mojom::NetLogCaptureMode::EVERYTHING;
|
||||
}
|
||||
|
||||
// TODO(eroman): Should fail if unrecognized mode rather than defaulting.
|
||||
NOTREACHED();
|
||||
return network::mojom::NetLogCaptureMode::DEFAULT;
|
||||
}
|
||||
|
||||
|
@ -43,11 +43,11 @@ const char kLogNetLog[] = "log-net-log";
|
||||
// Sets the granularity of events to capture in the network log. The mode can be
|
||||
// set to one of the following values:
|
||||
// "Default"
|
||||
// "IncludeCookiesAndCredentials"
|
||||
// "IncludeSocketBytes"
|
||||
// "IncludeSensitive"
|
||||
// "Everything"
|
||||
//
|
||||
// See the functions of the corresponding name in net_log_capture_mode.h for a
|
||||
// description of their meaning.
|
||||
// See the enums of the corresponding name in net_log_capture_mode.h for a
|
||||
// description of their meanings.
|
||||
const char kNetLogCaptureMode[] = "net-log-capture-mode";
|
||||
|
||||
// Causes SSL key material to be logged to the specified file for debugging
|
||||
|
@ -14,11 +14,11 @@ enum NetLogCaptureMode {
|
||||
|
||||
// Log all events, but do not include the actual transferred bytes as
|
||||
// parameters for bytes sent/received events.
|
||||
INCLUDE_COOKIES_AND_CREDENTIALS,
|
||||
INCLUDE_PRIVACY_INFO,
|
||||
|
||||
// Log everything possible, even if it is slow and memory expensive.
|
||||
// Includes logging of transferred bytes.
|
||||
INCLUDE_SOCKET_BYTES
|
||||
EVERYTHING
|
||||
};
|
||||
|
||||
// Manages export of ongoing NetLog events to a file.
|
||||
|
@ -29,7 +29,7 @@ namespace {
|
||||
base::Value CookieStoreOriginFiltered(const std::string& origin,
|
||||
bool is_https,
|
||||
net::NetLogCaptureMode capture_mode) {
|
||||
if (!capture_mode.include_cookies_and_credentials())
|
||||
if (!net::NetLogCaptureIncludesSensitive(capture_mode))
|
||||
return base::Value();
|
||||
base::DictionaryValue dict;
|
||||
dict.SetString("origin", origin);
|
||||
|
@ -167,7 +167,7 @@ TEST_F(SessionCleanupCookieStoreTest, TestNetLogDoNotIncludeCookies) {
|
||||
base::Time t = base::Time::Now();
|
||||
AddCookie("A", "B", "nonpersistent.com", "/", t);
|
||||
|
||||
net_log_.SetCaptureMode(net::NetLogCaptureMode::Default());
|
||||
net_log_.SetCaptureMode(net::NetLogCaptureMode::kDefault);
|
||||
// Cookies from "nonpersistent.com" should be deleted.
|
||||
store_->DeleteSessionCookies(
|
||||
base::BindRepeating([](const std::string& domain, bool is_https) {
|
||||
|
Reference in New Issue
Block a user