Commit 957f866a authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Always stop PrivetTrafficDetector.

Currently, there are some code paths in PrivetNotificationService where
PrivetTrafficDetector is not stopped. This causes PrivetTrafficDetector
to forget to unregister itself from NetworkConnectionTracker.

BUG=866199

Change-Id: I75721603889a6886b012d439bd6e8f2266083ee1
Reviewed-on: https://chromium-review.googlesource.com/1145888Reviewed-by: default avatarRobbie McElrath <rmcelrath@chromium.org>
Reviewed-by: default avatarHelen Li <xunjieli@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577220}
parent e8df742a
......@@ -209,8 +209,8 @@ PrivetNotificationService::PrivetNotificationService(
}
PrivetNotificationService::~PrivetNotificationService() {
#if BUILDFLAG(ENABLE_MDNS)
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
#if BUILDFLAG(ENABLE_MDNS)
if (traffic_detector_)
traffic_detector_->Stop();
#endif
......@@ -329,6 +329,10 @@ void PrivetNotificationService::Start() {
void PrivetNotificationService::OnNotificationsEnabledChanged() {
#if BUILDFLAG(ENABLE_MDNS)
if (traffic_detector_)
traffic_detector_->Stop();
traffic_detector_ = nullptr;
if (IsForced()) {
StartLister();
} else if (*enable_privet_notification_member_) {
......@@ -339,7 +343,6 @@ void PrivetNotificationService::OnNotificationsEnabledChanged() {
base::Bind(&PrivetNotificationService::StartLister, AsWeakPtr()));
traffic_detector_->Start();
} else {
traffic_detector_ = nullptr;
device_lister_.reset();
service_discovery_client_ = nullptr;
privet_notifications_listener_.reset();
......@@ -357,9 +360,6 @@ void PrivetNotificationService::OnNotificationsEnabledChanged() {
void PrivetNotificationService::StartLister() {
ReportPrivetUmaEvent(PRIVET_LISTER_STARTED);
#if BUILDFLAG(ENABLE_MDNS)
traffic_detector_ = nullptr;
#endif // ENABLE_MDNS
service_discovery_client_ =
local_discovery::ServiceDiscoverySharedClient::GetInstance();
device_lister_.reset(
......
......@@ -7,6 +7,7 @@
#include <map>
#include <memory>
#include <set>
#include <string>
#include "chrome/browser/printing/cloud_print/privet_device_lister.h"
......@@ -36,7 +37,7 @@ struct DeviceDescription;
#if BUILDFLAG(ENABLE_MDNS)
class PrivetTrafficDetector;
#endif // ENABLE_MDNS
#endif
// Contains logic related to notifications not tied actually displaying them.
class PrivetNotificationsListener {
......@@ -140,7 +141,7 @@ class PrivetNotificationService
#if BUILDFLAG(ENABLE_MDNS)
scoped_refptr<PrivetTrafficDetector> traffic_detector_;
#endif // ENABLE_MDNS
#endif
};
class PrivetNotificationDelegate : public message_center::NotificationDelegate {
......
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