| 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" |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 content::Source<Profile>(profile)); | 335 content::Source<Profile>(profile)); |
| 336 | 336 |
| 337 // Listen for extension uninstall, load, unloaded notification. | 337 // Listen for extension uninstall, load, unloaded notification. |
| 338 extension_registry_observer_.Add(extensions::ExtensionRegistry::Get(profile)); | 338 extension_registry_observer_.Add(extensions::ExtensionRegistry::Get(profile)); |
| 339 } | 339 } |
| 340 | 340 |
| 341 void BackgroundContentsService::Observe( | 341 void BackgroundContentsService::Observe( |
| 342 int type, | 342 int type, |
| 343 const content::NotificationSource& source, | 343 const content::NotificationSource& source, |
| 344 const content::NotificationDetails& details) { | 344 const content::NotificationDetails& details) { |
| 345 TRACE_EVENT0("browser,startup", "BackgroundContentsService::Observe"); |
| 345 switch (type) { | 346 switch (type) { |
| 346 case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED: { | 347 case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED: { |
| 347 const base::TimeTicks start_time = base::TimeTicks::Now(); | 348 SCOPED_UMA_HISTOGRAM_TIMER( |
| 349 "Extensions.BackgroundContentsServiceStartupTime"); |
| 348 Profile* profile = content::Source<Profile>(source).ptr(); | 350 Profile* profile = content::Source<Profile>(source).ptr(); |
| 349 LoadBackgroundContentsFromManifests(profile); | 351 LoadBackgroundContentsFromManifests(profile); |
| 350 LoadBackgroundContentsFromPrefs(profile); | 352 LoadBackgroundContentsFromPrefs(profile); |
| 351 SendChangeNotification(profile); | 353 SendChangeNotification(profile); |
| 352 UMA_HISTOGRAM_TIMES("Extensions.BackgroundContentsServiceStartupTime", | |
| 353 base::TimeTicks::Now() - start_time); | |
| 354 break; | 354 break; |
| 355 } | 355 } |
| 356 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: | 356 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: |
| 357 BackgroundContentsShutdown( | 357 BackgroundContentsShutdown( |
| 358 content::Details<BackgroundContents>(details).ptr()); | 358 content::Details<BackgroundContents>(details).ptr()); |
| 359 SendChangeNotification(content::Source<Profile>(source).ptr()); | 359 SendChangeNotification(content::Source<Profile>(source).ptr()); |
| 360 break; | 360 break; |
| 361 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED: | 361 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED: |
| 362 DCHECK(IsTracked(content::Details<BackgroundContents>(details).ptr())); | 362 DCHECK(IsTracked(content::Details<BackgroundContents>(details).ptr())); |
| 363 UnregisterBackgroundContents( | 363 UnregisterBackgroundContents( |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 bool user_gesture, | 772 bool user_gesture, |
| 773 bool* was_blocked) { | 773 bool* was_blocked) { |
| 774 Browser* browser = chrome::FindLastActiveWithProfile( | 774 Browser* browser = chrome::FindLastActiveWithProfile( |
| 775 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 775 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
| 776 chrome::GetActiveDesktop()); | 776 chrome::GetActiveDesktop()); |
| 777 if (browser) { | 777 if (browser) { |
| 778 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 778 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
| 779 initial_rect, user_gesture, was_blocked); | 779 initial_rect, user_gesture, was_blocked); |
| 780 } | 780 } |
| 781 } | 781 } |
| OLD | NEW |