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

Side by Side Diff: chrome/browser/extensions/warning_badge_service.cc

Issue 2912003002: Replace deprecated base::NonThreadSafe in chrome/browser/extensions in favor of SequenceChecker. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/warning_badge_service.h" 5 #include "chrome/browser/extensions/warning_badge_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 // static 95 // static
96 int ErrorBadge::GetMenuItemCommandID() { 96 int ErrorBadge::GetMenuItemCommandID() {
97 return IDC_EXTENSION_ERRORS; 97 return IDC_EXTENSION_ERRORS;
98 } 98 }
99 99
100 } // namespace 100 } // namespace
101 101
102 WarningBadgeService::WarningBadgeService(Profile* profile) 102 WarningBadgeService::WarningBadgeService(Profile* profile)
103 : profile_(profile), warning_service_observer_(this) { 103 : profile_(profile), warning_service_observer_(this) {
104 DCHECK(CalledOnValidThread()); 104 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
105 warning_service_observer_.Add(WarningService::Get(profile_)); 105 warning_service_observer_.Add(WarningService::Get(profile_));
106 } 106 }
107 107
108 WarningBadgeService::~WarningBadgeService() { 108 WarningBadgeService::~WarningBadgeService() {
109 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
109 } 110 }
110 111
111 // static 112 // static
112 WarningBadgeService* WarningBadgeService::Get( 113 WarningBadgeService* WarningBadgeService::Get(
113 content::BrowserContext* context) { 114 content::BrowserContext* context) {
114 return WarningBadgeServiceFactory::GetForBrowserContext(context); 115 return WarningBadgeServiceFactory::GetForBrowserContext(context);
115 } 116 }
116 117
117 void WarningBadgeService::SuppressCurrentWarnings() { 118 void WarningBadgeService::SuppressCurrentWarnings() {
118 DCHECK(CalledOnValidThread()); 119 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
119 size_t old_size = suppressed_warnings_.size(); 120 size_t old_size = suppressed_warnings_.size();
120 121
121 const WarningSet& warnings = GetCurrentWarnings(); 122 const WarningSet& warnings = GetCurrentWarnings();
122 suppressed_warnings_.insert(warnings.begin(), warnings.end()); 123 suppressed_warnings_.insert(warnings.begin(), warnings.end());
123 124
124 if (old_size != suppressed_warnings_.size()) 125 if (old_size != suppressed_warnings_.size())
125 UpdateBadgeStatus(); 126 UpdateBadgeStatus();
126 } 127 }
127 128
128 const WarningSet& WarningBadgeService::GetCurrentWarnings() const { 129 const WarningSet& WarningBadgeService::GetCurrentWarnings() const {
129 return WarningService::Get(profile_)->warnings(); 130 return WarningService::Get(profile_)->warnings();
130 } 131 }
131 132
132 void WarningBadgeService::ExtensionWarningsChanged( 133 void WarningBadgeService::ExtensionWarningsChanged(
133 const ExtensionIdSet& affected_extensions) { 134 const ExtensionIdSet& affected_extensions) {
134 DCHECK(CalledOnValidThread()); 135 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
135 UpdateBadgeStatus(); 136 UpdateBadgeStatus();
136 } 137 }
137 138
138 void WarningBadgeService::UpdateBadgeStatus() { 139 void WarningBadgeService::UpdateBadgeStatus() {
139 const std::set<Warning>& warnings = GetCurrentWarnings(); 140 const std::set<Warning>& warnings = GetCurrentWarnings();
140 bool non_suppressed_warnings_exist = false; 141 bool non_suppressed_warnings_exist = false;
141 for (std::set<Warning>::const_iterator i = warnings.begin(); 142 for (std::set<Warning>::const_iterator i = warnings.begin();
142 i != warnings.end(); ++i) { 143 i != warnings.end(); ++i) {
143 if (!base::ContainsKey(suppressed_warnings_, *i)) { 144 if (!base::ContainsKey(suppressed_warnings_, *i)) {
144 non_suppressed_warnings_exist = true; 145 non_suppressed_warnings_exist = true;
(...skipping 10 matching lines...) Expand all
155 ErrorBadge::GetMenuItemCommandID()); 156 ErrorBadge::GetMenuItemCommandID());
156 157
157 // Activate or hide the warning badge in case the current state is incorrect. 158 // Activate or hide the warning badge in case the current state is incorrect.
158 if (error && !show) 159 if (error && !show)
159 service->RemoveGlobalError(error); 160 service->RemoveGlobalError(error);
160 else if (!error && show) 161 else if (!error && show)
161 service->AddGlobalError(base::MakeUnique<ErrorBadge>(this)); 162 service->AddGlobalError(base::MakeUnique<ErrorBadge>(this));
162 } 163 }
163 164
164 } // namespace extensions 165 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698