Commit 5602e852 authored by Eric Stevenson's avatar Eric Stevenson Committed by Commit Bot

Revert "Enable bounded mode logging on chrome://net-export."

This reverts commit c2fadc96.

Reason for revert: Added static initializer to MonochromePublic.apk.

Original change's description:
> Enable bounded mode logging on chrome://net-export.
> 
> There is an option to configure the maximum size of the NetLog. The
> default is 100MiB.
> 
> Bug: 679030
> Change-Id: I9260d7ee895d589c4789a350ca4fe1dfc8617b65
> Reviewed-on: https://chromium-review.googlesource.com/571514
> Commit-Queue: Eric Roman <eroman@chromium.org>
> Reviewed-by: Helen Li <xunjieli@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#487602}

TBR=eroman@chromium.org,xunjieli@chromium.org

Change-Id: I7d8fb8daee69e381097b441f3ed42bd24ae252d1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 679030, 746430
Reviewed-on: https://chromium-review.googlesource.com/577197
Commit-Queue: Eric Stevenson <estevenson@chromium.org>
Reviewed-by: default avatarEric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487900}
parent 7c9a1aa9
......@@ -149,12 +149,10 @@ class NetExportMessageHandler
net_log::NetExportFileWriter::StateObserver>
state_observer_manager_;
// The capture mode and file size bound that the user chose in the UI when
// logging started is cached here and is read after a file path is chosen in
// the save dialog. Their values are only valid while the save dialog is open
// on the desktop UI.
// The capture mode the user chose in the UI when logging started is cached
// here and is read after a file path is chosen in the save dialog.
// Its value is only valid while the save dialog is open on the desktop UI.
net::NetLogCaptureMode capture_mode_;
size_t max_log_file_size_;
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
......@@ -219,21 +217,12 @@ void NetExportMessageHandler::OnEnableNotifyUIWithState(
void NetExportMessageHandler::OnStartNetLog(const base::ListValue* list) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::string capture_mode_string;
bool result = list->GetString(0, &capture_mode_string);
DCHECK(result);
const base::Value::ListStorage& params = list->GetList();
// Determine the capture mode.
capture_mode_ = net::NetLogCaptureMode::Default();
if (params.size() > 0 && params[0].is_string()) {
capture_mode_ = net_log::NetExportFileWriter::CaptureModeFromString(
params[0].GetString());
}
// Determine the max file size.
max_log_file_size_ = net_log::NetExportFileWriter::kNoLimit;
if (params.size() > 1 && params[1].is_int() && params[1].GetInt() > 0) {
max_log_file_size_ = params[1].GetInt();
}
capture_mode_ =
net_log::NetExportFileWriter::CaptureModeFromString(capture_mode_string);
if (UsingMobileUI()) {
StartNetLog(base::FilePath());
......@@ -332,7 +321,7 @@ void NetExportMessageHandler::StartNetLog(const base::FilePath& path) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
file_writer_->StartNetLog(
path, capture_mode_, max_log_file_size_,
path, capture_mode_,
base::CommandLine::ForCurrentProcess()->GetCommandLineString(),
chrome::GetChannelString(), GetURLRequestContexts());
}
......
......@@ -101,8 +101,6 @@ base::FilePath GetPathWithAllPermissions(const base::FilePath& path) {
} // namespace
const size_t NetExportFileWriter::kNoLimit = net::FileNetLogObserver::kNoLimit;
NetExportFileWriter::NetExportFileWriter(ChromeNetLog* chrome_net_log)
: state_(STATE_UNINITIALIZED),
log_exists_(false),
......@@ -158,7 +156,6 @@ void NetExportFileWriter::Initialize(
void NetExportFileWriter::StartNetLog(
const base::FilePath& log_path,
net::NetLogCaptureMode capture_mode,
size_t max_file_size,
const base::CommandLine::StringType& command_line_string,
const std::string& channel_string,
const URLRequestContextGetterList& context_getters) {
......@@ -180,8 +177,8 @@ void NetExportFileWriter::StartNetLog(
std::unique_ptr<base::Value> constants(
ChromeNetLog::GetConstants(command_line_string, channel_string));
file_net_log_observer_ = net::FileNetLogObserver::CreateBounded(
log_path_, max_file_size, std::move(constants));
file_net_log_observer_ =
net::FileNetLogObserver::CreateUnbounded(log_path_, std::move(constants));
net_task_runner_->PostTaskAndReply(
FROM_HERE,
......
......@@ -55,9 +55,6 @@ class ChromeNetLog;
// code on the |file_task_runner_| and |net_task_runner_|.
class NetExportFileWriter {
public:
// Special value meaning "can use an unlimited number of bytes".
static const size_t kNoLimit;
// The observer interface to be implemented by code that wishes to be notified
// of NetExportFileWriter's state changes.
class StateObserver {
......@@ -102,16 +99,12 @@ class NetExportFileWriter {
// empty, the default log path is used. If NetExportFileWriter is already
// logging, this is a no-op and |capture_mode| is ignored.
//
// |max_file_size| places a bound on how large the log file can grow. To make
// it grow unboundedly pass kNoLimit.
//
// |context_getters| is an optional list of URLRequestContextGetters used only
// to add log entries for ongoing events when logging starts. They are not
// used for retrieving polled data. All the contexts must be bound to the same
// thread.
void StartNetLog(const base::FilePath& log_path,
net::NetLogCaptureMode capture_mode,
size_t max_file_size,
const base::CommandLine::StringType& command_line_string,
const std::string& channel_string,
const URLRequestContextGetterList& context_getters);
......
......@@ -34,7 +34,6 @@
namespace {
const char kChannelString[] = "SomeChannel";
const size_t kMaxLogSizeBytes = 100 * 1024 * 1024; // 100MiB
// Keep this in sync with kLogRelativePath defined in net_export_file_writer.cc.
base::FilePath::CharType kLogRelativePath[] =
......@@ -330,7 +329,7 @@ class NetExportFileWriterTest : public ::testing::Test {
net::NetLogCaptureMode capture_mode,
const std::string& expected_capture_mode_string,
const URLRequestContextGetterList& context_getters) {
file_writer_.StartNetLog(custom_log_path, capture_mode, kMaxLogSizeBytes,
file_writer_.StartNetLog(custom_log_path, capture_mode,
base::CommandLine::StringType(), kChannelString,
context_getters);
std::unique_ptr<base::DictionaryValue> state =
......@@ -499,14 +498,14 @@ TEST_F(NetExportFileWriterTest, StartAndStopWithAllCaptureModes) {
// with various capture modes; they should all be ignored and result in no
// state change.
file_writer_.StartNetLog(base::FilePath(), capture_modes[i],
kMaxLogSizeBytes, base::CommandLine::StringType(),
kChannelString, URLRequestContextGetterList());
base::CommandLine::StringType(), kChannelString,
URLRequestContextGetterList());
file_writer_.StartNetLog(base::FilePath(), capture_modes[(i + 1) % 3],
kMaxLogSizeBytes, base::CommandLine::StringType(),
kChannelString, URLRequestContextGetterList());
base::CommandLine::StringType(), kChannelString,
URLRequestContextGetterList());
file_writer_.StartNetLog(base::FilePath(), capture_modes[(i + 2) % 3],
kMaxLogSizeBytes, base::CommandLine::StringType(),
kChannelString, URLRequestContextGetterList());
base::CommandLine::StringType(), kChannelString,
URLRequestContextGetterList());
// StopNetLog(), should result in state change. The capture mode should
// match that of the first StartNetLog() call (called by
......@@ -746,8 +745,8 @@ TEST_F(NetExportFileWriterTest, ReceiveStartWhileInitializing) {
// 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, URLRequestContextGetterList());
base::CommandLine::StringType(), kChannelString,
URLRequestContextGetterList());
// Now run the main message loop. Make sure StartNetLog() was ignored by
// checking that the next two states are "initializing" followed by
......@@ -777,8 +776,8 @@ TEST_F(NetExportFileWriterTest, ReceiveStartWhileStoppingLog) {
// |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, URLRequestContextGetterList());
base::CommandLine::StringType(), kChannelString,
URLRequestContextGetterList());
// 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
......
......@@ -20,7 +20,7 @@ button {
font-weight: bold;
margin: 10px auto;
padding: 1em;
width: 15em;
width: 14em;
}
h2 {
......
......@@ -70,13 +70,6 @@
Include raw bytes (will include cookies and credentials)
</label>
</div>
<div>
<label>
Maximum log size (megabytes):
<input id='log-max-filesize' value="100" size="4" />
(Blank means unlimited).
</label>
</div>
</div>
</div>
......@@ -143,12 +136,9 @@
<div id="toobig-read-more">
<ul>
<li>The maximum log size can be specified when starting
logging.</li>
<li>Compressing the log file before attaching is a good
idea.</li>
<li>Capture logs over a shorter period of time; stop
logging once the issue has reproduced.</li>
<li>Compressing the log file before attaching is a good idea.</li>
<li>If the log file is still too big, you can try capturing again,
but over a shorter period of time</li>
<li>Existing log files can be shrunk using
<a
href="https://chromium.googlesource.com/chromium/src/+/master/net/tools/truncate_net_log.py"
......
......@@ -37,7 +37,6 @@ var NetExportView = (function() {
var kIdPrivacyReadMoreDiv = 'privacy-read-more'
var kIdTooBigReadMoreLink = 'toobig-read-more-link';
var kIdTooBigReadMoreDiv = 'toobig-read-more'
var kIdLogMaxFileSizeInput = 'log-max-filesize'
/**
* @constructor
......@@ -57,21 +56,9 @@ var NetExportView = (function() {
* Starts saving NetLog data to a file.
*/
onStartLogging_: function() {
// Determine the capture mode to use.
var logMode =
document.querySelector('input[name="log-mode"]:checked').value;
// Determine the maximum file size, as the number of bytes (or -1 to mean
// no limit)
var maxLogFileSizeBytes = -1;
var fileSizeString = $(kIdLogMaxFileSizeInput).value;
var numMegabytes = parseFloat(fileSizeString);
if (!isNaN(numMegabytes)) {
// Convert to an integral number of bytes.
maxLogFileSizeBytes = Math.round(numMegabytes * 1024 * 1024);
}
chrome.send('startNetLog', [logMode, maxLogFileSizeBytes]);
chrome.send('startNetLog', [logMode]);
},
/**
......
......@@ -135,24 +135,14 @@ void NetExportMessageHandler::OnEnableNotifyUIWithState(
void NetExportMessageHandler::OnStartNetLog(const base::ListValue* list) {
DCHECK_CURRENTLY_ON(web::WebThread::UI);
std::string capture_mode_string;
bool result = list->GetString(0, &capture_mode_string);
DCHECK(result);
const base::Value::ListStorage& params = list->GetList();
// Determine the capture mode.
net::NetLogCaptureMode capture_mode = net::NetLogCaptureMode::Default();
if (params.size() > 0 && params[0].is_string()) {
capture_mode = net_log::NetExportFileWriter::CaptureModeFromString(
params[0].GetString());
}
// Determine the max file size.
size_t max_log_file_size = net_log::NetExportFileWriter::kNoLimit;
if (params.size() > 1 && params[1].is_int() && params[1].GetInt() > 0) {
max_log_file_size = params[1].GetInt();
}
net::NetLogCaptureMode capture_mode =
net_log::NetExportFileWriter::CaptureModeFromString(capture_mode_string);
file_writer_->StartNetLog(
base::FilePath(), capture_mode, max_log_file_size,
base::FilePath(), capture_mode,
base::CommandLine::ForCurrentProcess()->GetCommandLineString(),
GetChannelString(),
{GetApplicationContext()->GetSystemURLRequestContext()});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment