summaryrefslogtreecommitdiff
path: root/chromium/components/net_log
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-08-30 10:22:43 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-08-30 12:36:28 +0000
commit271a6c3487a14599023a9106329505597638d793 (patch)
treee040d58ffc86c1480b79ca8528020ca9ec919bf8 /chromium/components/net_log
parent7b2ffa587235a47d4094787d72f38102089f402a (diff)
downloadqtwebengine-chromium-271a6c3487a14599023a9106329505597638d793.tar.gz
BASELINE: Update Chromium to 77.0.3865.59
Change-Id: I1e89a5f3b009a9519a6705102ad65c92fe736f21 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/components/net_log')
-rw-r--r--chromium/components/net_log/chrome_net_log.cc59
-rw-r--r--chromium/components/net_log/chrome_net_log.h81
-rw-r--r--chromium/components/net_log/net_export_file_writer.cc21
-rw-r--r--chromium/components/net_log/net_export_file_writer.h5
-rw-r--r--chromium/components/net_log/net_export_file_writer_unittest.cc60
-rw-r--r--chromium/components/net_log/resources/OWNERS2
6 files changed, 66 insertions, 162 deletions
diff --git a/chromium/components/net_log/chrome_net_log.cc b/chromium/components/net_log/chrome_net_log.cc
index 661e1bd8a2a..ee4890ab074 100644
--- a/chromium/components/net_log/chrome_net_log.cc
+++ b/chromium/components/net_log/chrome_net_log.cc
@@ -4,44 +4,16 @@
#include "components/net_log/chrome_net_log.h"
-#include <memory>
-#include <utility>
-
-#include "base/callback.h"
#include "base/command_line.h"
-#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
#include "base/system/sys_info.h"
#include "base/values.h"
-#include "build/build_config.h"
#include "components/version_info/version_info.h"
-#include "net/log/file_net_log_observer.h"
#include "net/log/net_log_util.h"
namespace net_log {
-ChromeNetLog::ChromeNetLog() {}
-
-ChromeNetLog::~ChromeNetLog() {
- ClearFileNetLogObserver();
-}
-
-void ChromeNetLog::StartWritingToFile(
- const base::FilePath& path,
- net::NetLogCaptureMode capture_mode,
- const base::CommandLine::StringType& command_line_string,
- const std::string& channel_string) {
- DCHECK(!path.empty());
-
- // TODO(739485): The log file does not contain about:flags data.
- file_net_log_observer_ = net::FileNetLogObserver::CreateUnbounded(
- path, GetConstants(command_line_string, channel_string));
-
- file_net_log_observer_->StartObserving(this, capture_mode);
-}
-
-// static
-std::unique_ptr<base::Value> ChromeNetLog::GetConstants(
+std::unique_ptr<base::Value> GetConstantsForNetLog(
const base::CommandLine::StringType& command_line_string,
const std::string& channel_string) {
std::unique_ptr<base::DictionaryValue> constants_dict =
@@ -49,13 +21,13 @@ std::unique_ptr<base::Value> ChromeNetLog::GetConstants(
DCHECK(constants_dict);
auto platform_dict =
- GetPlatformConstants(command_line_string, channel_string);
+ GetPlatformConstantsForNetLog(command_line_string, channel_string);
if (platform_dict)
constants_dict->MergeDictionary(platform_dict.get());
return constants_dict;
}
-std::unique_ptr<base::DictionaryValue> ChromeNetLog::GetPlatformConstants(
+std::unique_ptr<base::DictionaryValue> GetPlatformConstantsForNetLog(
const base::CommandLine::StringType& command_line_string,
const std::string& channel_string) {
auto constants_dict = std::make_unique<base::DictionaryValue>();
@@ -83,29 +55,4 @@ std::unique_ptr<base::DictionaryValue> ChromeNetLog::GetPlatformConstants(
return constants_dict;
}
-void ChromeNetLog::ShutDownBeforeThreadPool() {
- // TODO(eroman): Stop in-progress net_export_file_writer_ or delete its files?
-
- ClearFileNetLogObserver();
-}
-
-void ChromeNetLog::ClearFileNetLogObserver() {
- if (!file_net_log_observer_)
- return;
-
- // TODO(739487): The log file does not contain any polled data.
- //
- // TODO(eroman): FileNetLogObserver::StopObserving() posts to the file task
- // runner to finish writing the log file. Despite that sequenced task runner
- // being marked BLOCK_SHUTDOWN, those tasks are not actually running.
- //
- // This isn't a big deal when using the unbounded logger since the log
- // loading code can handle such truncated logs. But this will need fixing
- // if switching to log formats that are not so versatile (also if adding
- // polled data).
- file_net_log_observer_->StopObserving(nullptr /*polled_data*/,
- base::Closure());
- file_net_log_observer_.reset();
-}
-
} // namespace net_log
diff --git a/chromium/components/net_log/chrome_net_log.h b/chromium/components/net_log/chrome_net_log.h
index 82cbd8f21c6..8c1052ce237 100644
--- a/chromium/components/net_log/chrome_net_log.h
+++ b/chromium/components/net_log/chrome_net_log.h
@@ -10,76 +10,35 @@
#include "base/command_line.h"
#include "base/macros.h"
-#include "net/log/net_log.h"
namespace base {
-class FilePath;
+class DictionaryValue;
class Value;
}
-namespace net {
-class FileNetLogObserver;
-}
-
namespace net_log {
-// ChromeNetLog is an implementation of NetLog that manages common observers
-// (for --log-net-log, chrome://net-export/, tracing), as well as acting as the
-// entry point for other consumers.
+// Returns all the constants to include in NetLog files. This includes both
+// platform-specific details (GetPlatformConstantsForNetLog()) as well as the
+// basic src/net constants (net::GetNetConstants()) for things like symbolic
+// names of error codes.
//
-// Threading:
-// * The methods on net::NetLog are threadsafe
-// * The methods defined by ChromeNetLog must be sequenced.
-class ChromeNetLog : public net::NetLog {
- public:
- ChromeNetLog();
- ~ChromeNetLog() override;
-
- // Starts streaming the NetLog events to a file on disk. This will continue
- // until the application shuts down.
- // * |path| - destination file path of the log file.
- // * |capture_mode| - capture mode for event granularity.
- void StartWritingToFile(
- const base::FilePath& path,
- net::NetLogCaptureMode capture_mode,
- const base::CommandLine::StringType& command_line_string,
- const std::string& channel_string);
-
- // Returns a Value containing constants needed to load a log file.
- // Safe to call on any thread.
- static std::unique_ptr<base::Value> GetConstants(
- const base::CommandLine::StringType& command_line_string,
- const std::string& channel_string);
-
- // Returns only platform-specific constants. This doesn't include the net/
- // baseline, only Chrome-specific platform information.
- static std::unique_ptr<base::DictionaryValue> GetPlatformConstants(
- const base::CommandLine::StringType& command_line_string,
- const std::string& channel_string);
+// Safe to call on any thread.
+std::unique_ptr<base::Value> GetConstantsForNetLog(
+ const base::CommandLine::StringType& command_line_string,
+ const std::string& channel_string);
- // Notify the ChromeNetLog that things are shutting-down.
- //
- // If ChromeNetLog does not outlive the ThreadPool, there is no need to
- // call this.
- //
- // However, if it can outlive the ThreadPool, this should be called
- // before the ThreadPool is shutdown. This allows for any file writers
- // using BLOCK_SHUTDOWN to finish posting their writes.
- //
- // Not calling this is not a fatal error, however may result in an incomplete
- // NetLog file being written to disk.
- void ShutDownBeforeThreadPool();
-
- private:
- // Deletes file_net_log_observer_.
- void ClearFileNetLogObserver();
-
- // This observer handles writing NetLogs specified via StartWritingToFile()
- // (In Chrome this corresponds to the --log-net-log command line).
- std::unique_ptr<net::FileNetLogObserver> file_net_log_observer_;
-
- DISALLOW_COPY_AND_ASSIGN(ChromeNetLog);
-};
+// Returns constants to include in NetLog files for debugging purposes, which
+// includes information such as:
+//
+// * The version and build of Chrome
+// * The command line arguments Chrome was launched with
+// * The operating system version
+//
+// Safe to call on any thread.
+std::unique_ptr<base::DictionaryValue> GetPlatformConstantsForNetLog(
+ const base::CommandLine::StringType& command_line_string,
+ const std::string& channel_string);
} // namespace net_log
diff --git a/chromium/components/net_log/net_export_file_writer.cc b/chromium/components/net_log/net_export_file_writer.cc
index 462818ec838..a64a35e259d 100644
--- a/chromium/components/net_log/net_export_file_writer.cc
+++ b/chromium/components/net_log/net_export_file_writer.cc
@@ -86,9 +86,8 @@ NetExportFileWriter::NetExportFileWriter()
: state_(STATE_UNINITIALIZED),
log_exists_(false),
log_capture_mode_known_(false),
- log_capture_mode_(net::NetLogCaptureMode::Default()),
- default_log_base_dir_getter_(base::Bind(&base::GetTempDir)),
- weak_ptr_factory_(this) {}
+ log_capture_mode_(net::NetLogCaptureMode::kDefault),
+ default_log_base_dir_getter_(base::Bind(&base::GetTempDir)) {}
NetExportFileWriter::~NetExportFileWriter() {
if (net_log_exporter_) {
@@ -150,7 +149,7 @@ void NetExportFileWriter::StartNetLog(
network_context->CreateNetLogExporter(mojo::MakeRequest(&net_log_exporter_));
base::Value custom_constants = base::Value::FromUniquePtrValue(
- ChromeNetLog::GetPlatformConstants(command_line_string, channel_string));
+ GetPlatformConstantsForNetLog(command_line_string, channel_string));
net_log_exporter_.set_connection_error_handler(base::BindOnce(
&NetExportFileWriter::OnConnectionError, base::Unretained(this)));
@@ -294,11 +293,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 +306,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(
diff --git a/chromium/components/net_log/net_export_file_writer.h b/chromium/components/net_log/net_export_file_writer.h
index 925524b913a..c7cfda7e143 100644
--- a/chromium/components/net_log/net_export_file_writer.h
+++ b/chromium/components/net_log/net_export_file_writer.h
@@ -35,8 +35,6 @@ class NetworkContext;
namespace net_log {
-class ChromeNetLog;
-
// NetExportFileWriter is used exclusively as a support class for
// chrome://net-export/. There's a single instance created globally that acts as
// the interface to all NetExportMessageHandlers which can tell it to start or
@@ -151,7 +149,6 @@ class NetExportFileWriter {
void SetDefaultLogBaseDirectoryGetterForTest(const DirectoryGetter& getter);
private:
- friend class ChromeNetLog;
friend class NetExportFileWriterTest;
// The possible logging states of NetExportFileWriter.
@@ -226,7 +223,7 @@ class NetExportFileWriter {
// during initialization. This getter is initialized to base::GetTempDir().
DirectoryGetter default_log_base_dir_getter_;
- base::WeakPtrFactory<NetExportFileWriter> weak_ptr_factory_;
+ base::WeakPtrFactory<NetExportFileWriter> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(NetExportFileWriter);
};
diff --git a/chromium/components/net_log/net_export_file_writer_unittest.cc b/chromium/components/net_log/net_export_file_writer_unittest.cc
index 2d628d76cd2..2d41be3bd39 100644
--- a/chromium/components/net_log/net_export_file_writer_unittest.cc
+++ b/chromium/components/net_log/net_export_file_writer_unittest.cc
@@ -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();
diff --git a/chromium/components/net_log/resources/OWNERS b/chromium/components/net_log/resources/OWNERS
new file mode 100644
index 00000000000..c05db2e16e1
--- /dev/null
+++ b/chromium/components/net_log/resources/OWNERS
@@ -0,0 +1,2 @@
+# For trivial or mechanical horizontal JS/CSS/HTML changes.
+file://ui/webui/PLATFORM_OWNERS