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

Unified Diff: components/cronet/android/cronet_url_request_context_adapter.cc

Issue 2102903004: [Cronet] Unregister NetLog observer during shutdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/cronet/android/cronet_url_request_context_adapter.cc
diff --git a/components/cronet/android/cronet_url_request_context_adapter.cc b/components/cronet/android/cronet_url_request_context_adapter.cc
index 8fc46678fe63c5de930f0861fa802c03fbf07497..09514022e1f9472199bbcdfc08d65fd4cc8f543a 100644
--- a/components/cronet/android/cronet_url_request_context_adapter.cc
+++ b/components/cronet/android/cronet_url_request_context_adapter.cc
@@ -413,6 +413,8 @@ CronetURLRequestContextAdapter::~CronetURLRequestContextAdapter() {
network_quality_estimator_->RemoveRTTObserver(this);
network_quality_estimator_->RemoveThroughputObserver(this);
}
+ // Stop |write_to_file_observer_| if there is one.
+ StopNetLogHelper();
}
void CronetURLRequestContextAdapter::InitRequestContextOnMainThread(
@@ -779,11 +781,7 @@ void CronetURLRequestContextAdapter::StartNetLogToFile(
void CronetURLRequestContextAdapter::StopNetLog(
JNIEnv* env,
const JavaParamRef<jobject>& jcaller) {
- base::AutoLock lock(write_to_file_observer_lock_);
- if (write_to_file_observer_) {
- write_to_file_observer_->StopObserving(/*url_request_context=*/nullptr);
- write_to_file_observer_.reset();
- }
+ StopNetLogHelper();
}
base::Thread* CronetURLRequestContextAdapter::GetFileThread() {
@@ -815,6 +813,14 @@ void CronetURLRequestContextAdapter::OnThroughputObservation(
(timestamp - base::TimeTicks::UnixEpoch()).InMilliseconds(), source);
}
+void CronetURLRequestContextAdapter::StopNetLogHelper() {
+ base::AutoLock lock(write_to_file_observer_lock_);
+ if (write_to_file_observer_) {
+ write_to_file_observer_->StopObserving(/*url_request_context=*/nullptr);
+ write_to_file_observer_.reset();
+ }
+}
+
// Create a URLRequestContextConfig from the given parameters.
static jlong CreateRequestContextConfig(
JNIEnv* env,

Powered by Google App Engine
This is Rietveld 408576698