Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/background/background_contents_service.h" | 5 #include "chrome/browser/background/background_contents_service.h" |
| 6 | 6 |
| 7 #include "apps/app_load_service.h" | 7 #include "apps/app_load_service.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/metrics/histogram.h" | |
|
Ilya Sherman
2015/02/05 02:50:26
nit: Please include histogram_macros instead.
Yoyo Zhou
2015/02/05 03:08:02
Done.
| |
| 13 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 14 #include "base/prefs/scoped_user_pref_update.h" | 15 #include "base/prefs/scoped_user_pref_update.h" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 18 #include "base/values.h" | 19 #include "base/values.h" |
| 19 #include "chrome/browser/background/background_contents_service_factory.h" | 20 #include "chrome/browser/background/background_contents_service_factory.h" |
| 20 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
| 22 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 // Listen for extension uninstall, load, unloaded notification. | 337 // Listen for extension uninstall, load, unloaded notification. |
| 337 extension_registry_observer_.Add(extensions::ExtensionRegistry::Get(profile)); | 338 extension_registry_observer_.Add(extensions::ExtensionRegistry::Get(profile)); |
| 338 } | 339 } |
| 339 | 340 |
| 340 void BackgroundContentsService::Observe( | 341 void BackgroundContentsService::Observe( |
| 341 int type, | 342 int type, |
| 342 const content::NotificationSource& source, | 343 const content::NotificationSource& source, |
| 343 const content::NotificationDetails& details) { | 344 const content::NotificationDetails& details) { |
| 344 switch (type) { | 345 switch (type) { |
| 345 case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED: { | 346 case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED: { |
| 347 const base::TimeTicks start_time = base::TimeTicks::Now(); | |
| 346 Profile* profile = content::Source<Profile>(source).ptr(); | 348 Profile* profile = content::Source<Profile>(source).ptr(); |
| 347 LoadBackgroundContentsFromManifests(profile); | 349 LoadBackgroundContentsFromManifests(profile); |
| 348 LoadBackgroundContentsFromPrefs(profile); | 350 LoadBackgroundContentsFromPrefs(profile); |
| 349 SendChangeNotification(profile); | 351 SendChangeNotification(profile); |
| 352 UMA_HISTOGRAM_TIMES("BackgroundContentsService.LoadOnExtensionsReadyTime", | |
| 353 base::TimeTicks::Now() - start_time); | |
| 350 break; | 354 break; |
| 351 } | 355 } |
| 352 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: | 356 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: |
| 353 BackgroundContentsShutdown( | 357 BackgroundContentsShutdown( |
| 354 content::Details<BackgroundContents>(details).ptr()); | 358 content::Details<BackgroundContents>(details).ptr()); |
| 355 SendChangeNotification(content::Source<Profile>(source).ptr()); | 359 SendChangeNotification(content::Source<Profile>(source).ptr()); |
| 356 break; | 360 break; |
| 357 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED: | 361 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED: |
| 358 DCHECK(IsTracked(content::Details<BackgroundContents>(details).ptr())); | 362 DCHECK(IsTracked(content::Details<BackgroundContents>(details).ptr())); |
| 359 UnregisterBackgroundContents( | 363 UnregisterBackgroundContents( |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 771 bool user_gesture, | 775 bool user_gesture, |
| 772 bool* was_blocked) { | 776 bool* was_blocked) { |
| 773 Browser* browser = chrome::FindLastActiveWithProfile( | 777 Browser* browser = chrome::FindLastActiveWithProfile( |
| 774 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 778 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
| 775 chrome::GetActiveDesktop()); | 779 chrome::GetActiveDesktop()); |
| 776 if (browser) { | 780 if (browser) { |
| 777 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 781 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
| 778 initial_pos, user_gesture, was_blocked); | 782 initial_pos, user_gesture, was_blocked); |
| 779 } | 783 } |
| 780 } | 784 } |
| OLD | NEW |