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

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

Issue 2825963003: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/extensions (Closed)
Patch Set: Created 3 years, 8 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/user_script_listener.h" 5 #include "chrome/browser/extensions/user_script_listener.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/timer/elapsed_timer.h" 10 #include "base/timer/elapsed_timer.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 auto* registry = 226 auto* registry =
227 ExtensionRegistry::Get(content::Source<Profile>(source).ptr()); 227 ExtensionRegistry::Get(content::Source<Profile>(source).ptr());
228 DCHECK(!extension_registry_observer_.IsObserving(registry)); 228 DCHECK(!extension_registry_observer_.IsObserving(registry));
229 extension_registry_observer_.Add(registry); 229 extension_registry_observer_.Add(registry);
230 break; 230 break;
231 } 231 }
232 case chrome::NOTIFICATION_PROFILE_DESTROYED: { 232 case chrome::NOTIFICATION_PROFILE_DESTROYED: {
233 Profile* profile = content::Source<Profile>(source).ptr(); 233 Profile* profile = content::Source<Profile>(source).ptr();
234 BrowserThread::PostTask( 234 BrowserThread::PostTask(
235 BrowserThread::IO, FROM_HERE, 235 BrowserThread::IO, FROM_HERE,
236 base::Bind(&UserScriptListener::ProfileDestroyed, this, profile)); 236 base::BindOnce(&UserScriptListener::ProfileDestroyed, this, profile));
237 break; 237 break;
238 } 238 }
239 case extensions::NOTIFICATION_USER_SCRIPTS_UPDATED: { 239 case extensions::NOTIFICATION_USER_SCRIPTS_UPDATED: {
240 Profile* profile = content::Source<Profile>(source).ptr(); 240 Profile* profile = content::Source<Profile>(source).ptr();
241 BrowserThread::PostTask( 241 BrowserThread::PostTask(
242 BrowserThread::IO, FROM_HERE, 242 BrowserThread::IO, FROM_HERE,
243 base::Bind(&UserScriptListener::UserScriptsReady, this, profile)); 243 base::BindOnce(&UserScriptListener::UserScriptsReady, this, profile));
244 break; 244 break;
245 } 245 }
246 default: 246 default:
247 NOTREACHED(); 247 NOTREACHED();
248 } 248 }
249 } 249 }
250 250
251 void UserScriptListener::OnExtensionLoaded( 251 void UserScriptListener::OnExtensionLoaded(
252 content::BrowserContext* browser_context, 252 content::BrowserContext* browser_context,
253 const Extension* extension) { 253 const Extension* extension) {
254 if (ContentScriptsInfo::GetContentScripts(extension).empty()) 254 if (ContentScriptsInfo::GetContentScripts(extension).empty())
255 return; // no new patterns from this extension. 255 return; // no new patterns from this extension.
256 256
257 URLPatterns new_patterns; 257 URLPatterns new_patterns;
258 CollectURLPatterns(extension, &new_patterns); 258 CollectURLPatterns(extension, &new_patterns);
259 if (!new_patterns.empty()) { 259 if (!new_patterns.empty()) {
260 BrowserThread::PostTask( 260 BrowserThread::PostTask(
261 BrowserThread::IO, FROM_HERE, 261 BrowserThread::IO, FROM_HERE,
262 base::Bind(&UserScriptListener::AppendNewURLPatterns, this, 262 base::BindOnce(&UserScriptListener::AppendNewURLPatterns, this,
263 browser_context, new_patterns)); 263 browser_context, new_patterns));
264 } 264 }
265 } 265 }
266 266
267 void UserScriptListener::OnExtensionUnloaded( 267 void UserScriptListener::OnExtensionUnloaded(
268 content::BrowserContext* browser_context, 268 content::BrowserContext* browser_context,
269 const Extension* extension, 269 const Extension* extension,
270 UnloadedExtensionInfo::Reason reason) { 270 UnloadedExtensionInfo::Reason reason) {
271 if (ContentScriptsInfo::GetContentScripts(extension).empty()) 271 if (ContentScriptsInfo::GetContentScripts(extension).empty())
272 return; // No patterns to delete for this extension. 272 return; // No patterns to delete for this extension.
273 273
274 // Clear all our patterns and reregister all the still-loaded extensions. 274 // Clear all our patterns and reregister all the still-loaded extensions.
275 const ExtensionSet& extensions = 275 const ExtensionSet& extensions =
276 ExtensionRegistry::Get(browser_context)->enabled_extensions(); 276 ExtensionRegistry::Get(browser_context)->enabled_extensions();
277 URLPatterns new_patterns; 277 URLPatterns new_patterns;
278 for (ExtensionSet::const_iterator it = extensions.begin(); 278 for (ExtensionSet::const_iterator it = extensions.begin();
279 it != extensions.end(); ++it) { 279 it != extensions.end(); ++it) {
280 if (it->get() != extension) 280 if (it->get() != extension)
281 CollectURLPatterns(it->get(), &new_patterns); 281 CollectURLPatterns(it->get(), &new_patterns);
282 } 282 }
283 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 283 BrowserThread::PostTask(
284 base::Bind(&UserScriptListener::ReplaceURLPatterns, 284 BrowserThread::IO, FROM_HERE,
285 this, browser_context, new_patterns)); 285 base::BindOnce(&UserScriptListener::ReplaceURLPatterns, this,
286 browser_context, new_patterns));
286 } 287 }
287 288
288 void UserScriptListener::OnShutdown(ExtensionRegistry* registry) { 289 void UserScriptListener::OnShutdown(ExtensionRegistry* registry) {
289 extension_registry_observer_.Remove(registry); 290 extension_registry_observer_.Remove(registry);
290 } 291 }
291 292
292 } // namespace extensions 293 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/updater/extension_updater.cc ('k') | chrome/browser/extensions/webstore_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698