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

Unified Diff: chrome/browser/ui/webui/conflicts_ui.cc

Issue 2037883004: [Win] Add reporting of total number of modules loaded in browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small fixes. Created 4 years, 4 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/ui/webui/conflicts_ui.cc
diff --git a/chrome/browser/ui/webui/conflicts_ui.cc b/chrome/browser/ui/webui/conflicts_ui.cc
index d1e0e1d06fe87529c11e8634fa453835ede4bed4..b08e94b67df65b64ad99bf4bbbc2c95ec4428e3c 100644
--- a/chrome/browser/ui/webui/conflicts_ui.cc
+++ b/chrome/browser/ui/webui/conflicts_ui.cc
@@ -16,15 +16,11 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/win/enumerate_modules_model.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
-#include "content/public/browser/notification_service.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
@@ -77,9 +73,9 @@ content::WebUIDataSource* CreateConflictsUIHTMLSource() {
//
////////////////////////////////////////////////////////////////////////////////
-// The handler for JavaScript messages for the about:flags page.
+// The handler for JavaScript messages for the about:conflicts page.
class ConflictsDOMHandler : public WebUIMessageHandler,
- public content::NotificationObserver {
+ public EnumerateModulesModel::Observer {
public:
ConflictsDOMHandler() {}
~ConflictsDOMHandler() override {}
@@ -93,11 +89,8 @@ class ConflictsDOMHandler : public WebUIMessageHandler,
private:
void SendModuleList();
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
-
- content::NotificationRegistrar registrar_;
+ // EnumerateModulesModel::Observer implementation.
+ void OnScanCompleted() override;
DISALLOW_COPY_AND_ASSIGN(ConflictsDOMHandler);
};
@@ -109,10 +102,11 @@ void ConflictsDOMHandler::RegisterMessages() {
}
void ConflictsDOMHandler::HandleRequestModuleList(const base::ListValue* args) {
- // This request is handled asynchronously. See Observe for when we reply back.
- registrar_.Add(this, chrome::NOTIFICATION_MODULE_LIST_ENUMERATED,
- content::NotificationService::AllSources());
- EnumerateModulesModel::GetInstance()->ScanNow();
+ // The request is handled asynchronously, and will callback via
+ // OnScanCompleted on completion.
+ auto model = EnumerateModulesModel::GetInstance();
Lei Zhang 2016/08/04 14:33:32 auto*
chrisha 2016/08/12 19:04:40 Done.
+ model->AddObserver(this);
Lei Zhang 2016/08/04 14:33:32 Can this end up adding the same observer twice? Th
Peter Kasting 2016/08/05 00:10:08 If this is a real concern, using a ScopedObserver
chrisha 2016/08/12 19:04:40 The ScopedObserver is cleaner IMO, and also allows
chrisha 2016/08/12 19:04:40 Shouldn't be possible from how the JS code is writ
+ model->ScanNow();
}
void ConflictsDOMHandler::SendModuleList() {
@@ -141,13 +135,9 @@ void ConflictsDOMHandler::SendModuleList() {
web_ui()->CallJavascriptFunctionUnsafe("returnModuleList", results);
}
-void ConflictsDOMHandler::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(chrome::NOTIFICATION_MODULE_LIST_ENUMERATED, type);
-
+void ConflictsDOMHandler::OnScanCompleted() {
SendModuleList();
- registrar_.RemoveAll();
+ EnumerateModulesModel::GetInstance()->RemoveObserver(this);
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698