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

Unified Diff: components/net_log/chrome_net_log.h

Issue 2973673003: Use FileNetLogObserver for implementing --log-net-log. (Closed)
Patch Set: check for null Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/net_log/chrome_net_log.h
diff --git a/components/net_log/chrome_net_log.h b/components/net_log/chrome_net_log.h
index 42c0c2a56dbc5068366da2cfe069be13553c6ec1..11cc8517495f979c8c0c56ba5f32b2cb7faf488c 100644
--- a/components/net_log/chrome_net_log.h
+++ b/components/net_log/chrome_net_log.h
@@ -18,7 +18,7 @@ class Value;
}
namespace net {
-class WriteToFileNetLogObserver;
+class FileNetLogObserver;
class TraceNetLogObserver;
}
@@ -29,6 +29,9 @@ class NetExportFileWriter;
// 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.
+//
+// Threading: the underlying net::NetLog is threadsafe. Whereas the methods
+// added by ChromeNetLog must be sequenced.
mmenke 2017/07/06 21:31:29 Remove Whereas? At least I can't recall seeing us
eroman 2017/07/06 21:57:54 Done.
class ChromeNetLog : public net::NetLog {
public:
ChromeNetLog();
@@ -36,11 +39,11 @@ class ChromeNetLog : public net::NetLog {
// Starts streaming the NetLog events to a file on disk. This will continue
// until the application shuts down.
- // * |log_file| - path to write the file.
- // * |log_file_mode| - capture mode for event granularity.
+ // * |path| - destination file path of the log file.
+ // * |capture_mode| - capture mode for event granularity.
void StartWritingToFile(
- const base::FilePath& log_file,
- net::NetLogCaptureMode log_file_mode,
+ const base::FilePath& path,
+ net::NetLogCaptureMode capture_mode,
const base::CommandLine::StringType& command_line_string,
const std::string& channel_string);
@@ -52,9 +55,31 @@ class ChromeNetLog : public net::NetLog {
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 TaskScheduler, there is no need to
+ // call this.
+ //
+ // However, if it can outlive the TaskScheduler, this should be called
+ // before the TaskScheduler is shutdown. This allows for any file writers
+ // using the BLOCK_SHUTDOWN to finish posting their writes.
mmenke 2017/07/06 21:31:29 -the
eroman 2017/07/06 21:57:54 Done.
+ //
+ // Not calling this is not a fatal error, however may result in an incomplete
+ // NetLog file being written to disk.
+ void ShutdownBeforeTaskScheduler();
+
private:
- std::unique_ptr<net::WriteToFileNetLogObserver> write_to_file_observer_;
+ // 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_;
mmenke 2017/07/06 21:31:29 I hadn't realized we had three different file writ
eroman 2017/07/06 21:57:54 There are 3 observers here, but technically only 2
mmenke 2017/07/06 22:03:48 I was counting NetExportFileWriter, actually. Had
+
+ // This observer handles writing NetLogs started by chrome://net-export/
std::unique_ptr<NetExportFileWriter> net_export_file_writer_;
+
+ // This observer forwards NetLog events to the chrome://tracing system.
std::unique_ptr<net::TraceNetLogObserver> trace_net_log_observer_;
DISALLOW_COPY_AND_ASSIGN(ChromeNetLog);

Powered by Google App Engine
This is Rietveld 408576698