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

Unified Diff: net/log/file_net_log_observer.cc

Issue 2603523002: Move net-export thread-hopping code into NetLogFileWriter and add IO polled data. (Closed)
Patch Set: Fixed tommycli's nits from patchset 13 Created 3 years, 11 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
« no previous file with comments | « net/log/file_net_log_observer.h ('k') | net/log/file_net_log_observer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/log/file_net_log_observer.cc
diff --git a/net/log/file_net_log_observer.cc b/net/log/file_net_log_observer.cc
index e49452df8324ff63e717892198f6fb070d7fe7b3..8f1970164f3c79a692132bd7fab5ba69c69b4656 100644
--- a/net/log/file_net_log_observer.cc
+++ b/net/log/file_net_log_observer.cc
@@ -117,10 +117,10 @@ class FileNetLogObserver::FileWriter {
// Stop()).
virtual void Initialize(std::unique_ptr<base::Value> constants_value) = 0;
- // Closes the events array opened in Initialize() and writes |tab_info| to
- // disk. If |tab_info| cannot be converted to proper JSON, then it
+ // Closes the events array opened in Initialize() and writes |polled_data| to
+ // disk. If |polled_data| cannot be converted to proper JSON, then it
// is ignored.
- virtual void Stop(std::unique_ptr<base::Value> tab_info) = 0;
+ virtual void Stop(std::unique_ptr<base::Value> polled_data) = 0;
// Drains |queue_| from WriteQueue into a local file queue and writes the
// events in the queue to disk.
@@ -147,7 +147,7 @@ class FileNetLogObserver::BoundedFileWriter
// FileNetLogObserver::FileWriter implementation
void Initialize(std::unique_ptr<base::Value> constants_value) override;
- void Stop(std::unique_ptr<base::Value> tab_info) override;
+ void Stop(std::unique_ptr<base::Value> polled_data) override;
void Flush(scoped_refptr<WriteQueue> write_queue) override;
void DeleteAllFiles() override;
@@ -196,7 +196,7 @@ class FileNetLogObserver::UnboundedFileWriter
// FileNetLogObserver::FileWriter implementation
void Initialize(std::unique_ptr<base::Value> constants_value) override;
- void Stop(std::unique_ptr<base::Value> tab_info) override;
+ void Stop(std::unique_ptr<base::Value> polled_data) override;
void Flush(scoped_refptr<WriteQueue> write_queue) override;
void DeleteAllFiles() override;
@@ -297,7 +297,7 @@ void FileNetLogObserver::StartObservingHelper(
net_log->DeprecatedAddObserver(this, capture_mode);
}
-void FileNetLogObserver::StopObserving(URLRequestContext* url_request_context,
+void FileNetLogObserver::StopObserving(std::unique_ptr<base::Value> polled_data,
const base::Closure& callback) {
file_task_runner_->PostTask(
FROM_HERE, base::Bind(&FileNetLogObserver::FileWriter::Flush,
@@ -305,11 +305,8 @@ void FileNetLogObserver::StopObserving(URLRequestContext* url_request_context,
file_task_runner_->PostTaskAndReply(
FROM_HERE,
- base::Bind(
- &FileNetLogObserver::FileWriter::Stop, base::Unretained(file_writer_),
- base::Passed(url_request_context ? GetNetInfo(url_request_context,
- NET_INFO_ALL_SOURCES)
- : nullptr)),
+ base::Bind(&FileNetLogObserver::FileWriter::Stop,
+ base::Unretained(file_writer_), base::Passed(&polled_data)),
callback);
net_log()->DeprecatedRemoveObserver(this);
@@ -354,6 +351,7 @@ size_t FileNetLogObserver::WriteQueue::AddEntryToQueue(
return queue_.size();
}
+
void FileNetLogObserver::WriteQueue::SwapQueue(EventQueue* local_queue) {
DCHECK(local_queue->empty());
base::AutoLock lock(lock_);
@@ -401,18 +399,18 @@ void FileNetLogObserver::BoundedFileWriter::Initialize(
}
void FileNetLogObserver::BoundedFileWriter::Stop(
- std::unique_ptr<base::Value> tab_info) {
+ std::unique_ptr<base::Value> polled_data) {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
base::ScopedFILE closing_file(
base::OpenFile(directory_.AppendASCII("end_netlog.json"), "w"));
std::string json;
- if (tab_info)
- base::JSONWriter::Write(*tab_info, &json);
+ if (polled_data)
+ base::JSONWriter::Write(*polled_data, &json);
fprintf(closing_file.get(), "]%s}\n",
- json.empty() ? "" : (",\"tabInfo\": " + json + "\n").c_str());
+ json.empty() ? "" : (",\n\"polledData\": " + json + "\n").c_str());
// Flush all fprintfs to disk so that files can be safely accessed on
// callback.
@@ -496,15 +494,15 @@ void FileNetLogObserver::UnboundedFileWriter::Initialize(
}
void FileNetLogObserver::UnboundedFileWriter::Stop(
- std::unique_ptr<base::Value> tab_info) {
+ std::unique_ptr<base::Value> polled_data) {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
std::string json;
- if (tab_info)
- base::JSONWriter::Write(*tab_info, &json);
+ if (polled_data)
+ base::JSONWriter::Write(*polled_data, &json);
fprintf(file_.get(), "]%s}\n",
- json.empty() ? "" : (",\n\"tabInfo\": " + json + "\n").c_str());
+ json.empty() ? "" : (",\n\"polledData\": " + json + "\n").c_str());
// Flush all fprintfs to disk so that the file can be safely accessed on
// callback.
« no previous file with comments | « net/log/file_net_log_observer.h ('k') | net/log/file_net_log_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698