From e0860ea7a0cf963825b9ad3d8c6e1d1c99672351 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Thu, 2 Nov 2017 19:30:16 +0530 Subject: [PATCH] Stop file observer of NetLog to finish writing to disk --- brightray/browser/net_log.cc | 5 ++++- brightray/browser/net_log.h | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/brightray/browser/net_log.cc b/brightray/browser/net_log.cc index 3a949a44307e..1ac254cf145c 100644 --- a/brightray/browser/net_log.cc +++ b/brightray/browser/net_log.cc @@ -6,6 +6,7 @@ #include +#include "base/callback.h" #include "base/command_line.h" #include "base/files/file_path.h" #include "base/memory/ptr_util.h" @@ -37,6 +38,8 @@ NetLog::NetLog() { } NetLog::~NetLog() { + file_net_log_observer_->StopObserving(nullptr, base::Closure()); + file_net_log_observer_.reset(); } void NetLog::StartLogging() { @@ -50,7 +53,7 @@ void NetLog::StartLogging() { net::NetLogCaptureMode capture_mode = net::NetLogCaptureMode::IncludeCookiesAndCredentials(); - std::unique_ptr file_net_log_observer_ = + file_net_log_observer_ = net::FileNetLogObserver::CreateUnbounded(log_path, std::move(constants)); file_net_log_observer_->StartObserving(this, capture_mode); } diff --git a/brightray/browser/net_log.h b/brightray/browser/net_log.h index 0edae26f7673..0359767f0741 100644 --- a/brightray/browser/net_log.h +++ b/brightray/browser/net_log.h @@ -7,6 +7,10 @@ #include "net/log/net_log.h" +namespace net { +class FileNetLogObserver; +} + namespace brightray { class NetLog : public net::NetLog { @@ -17,6 +21,9 @@ class NetLog : public net::NetLog { void StartLogging(); private: + // This observer handles writing NetLogs. + std::unique_ptr file_net_log_observer_; + DISALLOW_COPY_AND_ASSIGN(NetLog); };