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

Unified Diff: chrome/browser/service_process/service_process_control.cc

Issue 2925973002: Migrate upgrade notifications to observer (Closed)
Patch Set: Fix test failure Created 3 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: chrome/browser/service_process/service_process_control.cc
diff --git a/chrome/browser/service_process/service_process_control.cc b/chrome/browser/service_process/service_process_control.cc
index c0499002c0ced58eab560da8226a7e7f9893f41d..2df31951c439bd0074b980195f5610ac6706cea5 100644
--- a/chrome/browser/service_process/service_process_control.cc
+++ b/chrome/browser/service_process/service_process_control.cc
@@ -25,12 +25,10 @@
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/upgrade_detector.h"
#include "chrome/common/service_messages.h"
#include "chrome/common/service_process_util.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_service.h"
#include "ipc/ipc_channel_mojo.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/named_platform_handle.h"
@@ -87,9 +85,12 @@ void ConnectAsyncWithBackoff(
} // namespace
// ServiceProcessControl implementation.
-ServiceProcessControl::ServiceProcessControl() : weak_factory_(this) {}
+ServiceProcessControl::ServiceProcessControl() : weak_factory_(this) {
+ UpgradeDetector::GetInstance()->AddObserver(this);
+}
ServiceProcessControl::~ServiceProcessControl() {
+ UpgradeDetector::GetInstance()->RemoveObserver(this);
}
void ServiceProcessControl::ConnectInternal() {
@@ -244,10 +245,6 @@ void ServiceProcessControl::OnChannelConnected(int32_t peer_pid) {
// upgrade is available.
if (UpgradeDetector::GetInstance()->notify_upgrade()) {
Send(new ServiceMsg_UpdateAvailable);
- } else {
- if (registrar_.IsEmpty())
- registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
- content::NotificationService::AllSources());
}
RunConnectDoneTasks();
}
@@ -270,12 +267,7 @@ bool ServiceProcessControl::Send(IPC::Message* message) {
return channel_->Send(message);
}
-// content::NotificationObserver implementation.
-void ServiceProcessControl::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type);
sky 2017/06/07 23:01:41 Previously the observer was only added in a certai
weidongg 2017/06/08 02:28:42 This function will be called multiple times. So I
+void ServiceProcessControl::OnUpgradeRecommended() {
Send(new ServiceMsg_UpdateAvailable);
}

Powered by Google App Engine
This is Rietveld 408576698