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

Side by Side Diff: chrome/browser/background/background_contents_service.cc

Issue 933423003: Make BackgroundContentsService start up BackgroundContents with a delay, as for ExtensionHosts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 5 years, 10 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/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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 BackgroundContents* contents = CreateBackgroundContents( 627 BackgroundContents* contents = CreateBackgroundContents(
628 SiteInstance::CreateForURL(profile, url), 628 SiteInstance::CreateForURL(profile, url),
629 MSG_ROUTING_NONE, 629 MSG_ROUTING_NONE,
630 MSG_ROUTING_NONE, 630 MSG_ROUTING_NONE,
631 profile, 631 profile,
632 frame_name, 632 frame_name,
633 application_id, 633 application_id,
634 std::string(), 634 std::string(),
635 NULL); 635 NULL);
636 636
637 // TODO(atwilson): Create RenderViews asynchronously to avoid increasing 637 contents->CreateRenderViewSoon(url);
638 // startup latency (http://crbug.com/47236).
639 contents->web_contents()->GetController().LoadURL(
640 url, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
641 } 638 }
642 639
643 BackgroundContents* BackgroundContentsService::CreateBackgroundContents( 640 BackgroundContents* BackgroundContentsService::CreateBackgroundContents(
644 SiteInstance* site, 641 SiteInstance* site,
645 int routing_id, 642 int routing_id,
646 int main_frame_route_id, 643 int main_frame_route_id,
647 Profile* profile, 644 Profile* profile,
648 const base::string16& frame_name, 645 const base::string16& frame_name,
649 const base::string16& application_id, 646 const base::string16& application_id,
650 const std::string& partition_id, 647 const std::string& partition_id,
651 content::SessionStorageNamespace* session_storage_namespace) { 648 content::SessionStorageNamespace* session_storage_namespace) {
652 BackgroundContents* contents = new BackgroundContents( 649 BackgroundContents* contents = new BackgroundContents(
653 site, routing_id, main_frame_route_id, this, partition_id, 650 site, routing_id, main_frame_route_id, this, partition_id,
654 session_storage_namespace); 651 session_storage_namespace);
655 652
656 // Register the BackgroundContents internally, then send out a notification 653 // Register the BackgroundContents internally, then send out a notification
657 // to external listeners. 654 // to external listeners.
658 BackgroundContentsOpenedDetails details = {contents, 655 BackgroundContentsOpenedDetails details = {contents,
659 frame_name, 656 frame_name,
660 application_id}; 657 application_id};
661 BackgroundContentsOpened(&details, profile); 658 BackgroundContentsOpened(&details, profile);
Devlin 2015/02/18 23:22:12 Andrew will probably know better, but do we need t
Yoyo Zhou 2015/02/19 02:55:37 Adding tengs to comment, since DriveWebContentsMan
662 content::NotificationService::current()->Notify( 659 content::NotificationService::current()->Notify(
663 chrome::NOTIFICATION_BACKGROUND_CONTENTS_OPENED, 660 chrome::NOTIFICATION_BACKGROUND_CONTENTS_OPENED,
664 content::Source<Profile>(profile), 661 content::Source<Profile>(profile),
665 content::Details<BackgroundContentsOpenedDetails>(&details)); 662 content::Details<BackgroundContentsOpenedDetails>(&details));
666 663
667 // A new background contents has been created - notify our listeners. 664 // A new background contents has been created - notify our listeners.
668 SendChangeNotification(profile); 665 SendChangeNotification(profile);
669 return contents; 666 return contents;
670 } 667 }
671 668
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 bool user_gesture, 772 bool user_gesture,
776 bool* was_blocked) { 773 bool* was_blocked) {
777 Browser* browser = chrome::FindLastActiveWithProfile( 774 Browser* browser = chrome::FindLastActiveWithProfile(
778 Profile::FromBrowserContext(new_contents->GetBrowserContext()), 775 Profile::FromBrowserContext(new_contents->GetBrowserContext()),
779 chrome::GetActiveDesktop()); 776 chrome::GetActiveDesktop());
780 if (browser) { 777 if (browser) {
781 chrome::AddWebContents(browser, NULL, new_contents, disposition, 778 chrome::AddWebContents(browser, NULL, new_contents, disposition,
782 initial_rect, user_gesture, was_blocked); 779 initial_rect, user_gesture, was_blocked);
783 } 780 }
784 } 781 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698