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

Unified Diff: chrome/browser/notifications/message_center_settings_controller.cc

Issue 1657913003: Refactor of ProfileInfoCache in c/b/notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/notifications/message_center_settings_controller.cc
diff --git a/chrome/browser/notifications/message_center_settings_controller.cc b/chrome/browser/notifications/message_center_settings_controller.cc
index f67ee396c3e2f1b351e7e79d4e8798a5c9193cea..6a7574e6a66a4a660339b06f55251453ab362d23 100644
--- a/chrome/browser/notifications/message_center_settings_controller.cc
+++ b/chrome/browser/notifications/message_center_settings_controller.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/notifications/message_center_settings_controller.h"
#include <algorithm>
+#include <string>
#include <utility>
#include "base/command_line.h"
@@ -22,6 +23,8 @@
#include "chrome/browser/notifications/notifier_state_tracker.h"
#include "chrome/browser/notifications/notifier_state_tracker_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_attributes_entry.h"
+#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/extensions/api/notifications.h"
@@ -120,11 +123,10 @@ class NotifierComparator {
} // namespace
MessageCenterSettingsController::MessageCenterSettingsController(
- ProfileInfoCache* profile_info_cache)
+ ProfileAttributesStorage& storage)
: current_notifier_group_(0),
- profile_info_cache_(profile_info_cache),
+ storage_(storage),
weak_factory_(this) {
- DCHECK(profile_info_cache_);
// The following events all represent changes that may need to be reflected in
// the profile selector context menu, so listen for them all. We'll just
// rebuild the list when we get any of them.
@@ -137,7 +139,7 @@ MessageCenterSettingsController::MessageCenterSettingsController(
registrar_.Add(this,
chrome::NOTIFICATION_PROFILE_DESTROYED,
content::NotificationService::AllBrowserContextsAndSources());
- g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
+ storage_.AddObserver(this);
RebuildNotifierGroups(false);
#if defined(OS_CHROMEOS)
@@ -148,8 +150,7 @@ MessageCenterSettingsController::MessageCenterSettingsController(
}
MessageCenterSettingsController::~MessageCenterSettingsController() {
- g_browser_process->profile_manager()->
- GetProfileInfoCache().RemoveObserver(this);
+ storage_.RemoveObserver(this);
#if defined(OS_CHROMEOS)
// UserManager may not exist in some tests.
if (user_manager::UserManager::IsInitialized())
@@ -507,15 +508,18 @@ void MessageCenterSettingsController::RebuildNotifierGroups(bool notify) {
notifier_groups_.clear();
current_notifier_group_ = 0;
- const size_t count = profile_info_cache_->GetNumberOfProfiles();
- for (size_t i = 0; i < count; ++i) {
+ std::vector<ProfileAttributesEntry*> entries =
+ storage_.GetAllProfilesAttributes();
+ ProfileInfoCache& cache = g_browser_process->profile_manager()->
+ GetProfileInfoCache();
+ for (const auto entry : entries) {
scoped_ptr<message_center::ProfileNotifierGroup> group(
new message_center::ProfileNotifierGroup(
- profile_info_cache_->GetAvatarIconOfProfileAtIndex(i),
- profile_info_cache_->GetNameOfProfileAtIndex(i),
- profile_info_cache_->GetUserNameOfProfileAtIndex(i),
- i,
- profile_info_cache_->GetPathOfProfileAtIndex(i)));
+ entry->GetAvatarIcon(),
+ entry->GetName(),
+ entry->GetUserName(),
+ cache.GetIndexOfProfileWithPath(entry->GetPath()),
+ entry->GetPath()));
lwchkg 2016/02/03 17:40:12 Do you know what is the use of the index in Profil
dewittj 2016/02/03 17:43:59 According to code search it isn't used at all. I
if (group->profile() == NULL)
continue;

Powered by Google App Engine
This is Rietveld 408576698