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

Side by Side Diff: chrome/browser/sessions/session_restore.cc

Issue 1052733002: Decouple TabLoader from SessionRestore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sky@ review. Created 5 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/sessions/session_restore.h" 5 #include "chrome/browser/sessions/session_restore.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/debug/alias.h" 16 #include "base/debug/alias.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/scoped_vector.h" 18 #include "base/memory/scoped_vector.h"
19 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
20 #include "base/run_loop.h" 20 #include "base/run_loop.h"
21 #include "base/stl_util.h" 21 #include "base/stl_util.h"
22 #include "base/task/cancelable_task_tracker.h" 22 #include "base/task/cancelable_task_tracker.h"
23 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/chrome_notification_types.h" 24 #include "chrome/browser/chrome_notification_types.h"
25 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/search/search.h" 26 #include "chrome/browser/search/search.h"
27 #include "chrome/browser/sessions/session_restore_delegate.h"
27 #include "chrome/browser/sessions/session_service.h" 28 #include "chrome/browser/sessions/session_service.h"
28 #include "chrome/browser/sessions/session_service_factory.h" 29 #include "chrome/browser/sessions/session_service_factory.h"
29 #include "chrome/browser/sessions/session_service_utils.h" 30 #include "chrome/browser/sessions/session_service_utils.h"
30 #include "chrome/browser/sessions/tab_loader.h" 31 #include "chrome/browser/sessions/tab_loader.h"
31 #include "chrome/browser/ui/browser.h" 32 #include "chrome/browser/ui/browser.h"
32 #include "chrome/browser/ui/browser_finder.h" 33 #include "chrome/browser/ui/browser_finder.h"
33 #include "chrome/browser/ui/browser_navigator.h" 34 #include "chrome/browser/ui/browser_navigator.h"
34 #include "chrome/browser/ui/browser_tabrestore.h" 35 #include "chrome/browser/ui/browser_tabrestore.h"
35 #include "chrome/browser/ui/browser_tabstrip.h" 36 #include "chrome/browser/ui/browser_tabstrip.h"
36 #include "chrome/browser/ui/browser_window.h" 37 #include "chrome/browser/ui/browser_window.h"
(...skipping 16 matching lines...) Expand all
53 #include "extensions/browser/extension_registry.h" 54 #include "extensions/browser/extension_registry.h"
54 #include "extensions/common/extension_set.h" 55 #include "extensions/common/extension_set.h"
55 56
56 #if defined(OS_CHROMEOS) 57 #if defined(OS_CHROMEOS)
57 #include "chrome/browser/chromeos/boot_times_recorder.h" 58 #include "chrome/browser/chromeos/boot_times_recorder.h"
58 #endif 59 #endif
59 60
60 using content::NavigationController; 61 using content::NavigationController;
61 using content::RenderWidgetHost; 62 using content::RenderWidgetHost;
62 using content::WebContents; 63 using content::WebContents;
64 using RestoredTab = SessionRestoreDelegate::RestoredTab;
63 65
64 namespace { 66 namespace {
65 67
66 class SessionRestoreImpl; 68 class SessionRestoreImpl;
67 69
68 // Pointers to SessionRestoreImpls which are currently restoring the session. 70 // Pointers to SessionRestoreImpls which are currently restoring the session.
69 std::set<SessionRestoreImpl*>* active_session_restorers = nullptr; 71 std::set<SessionRestoreImpl*>* active_session_restorers = nullptr;
70 72
71 // SessionRestoreImpl --------------------------------------------------------- 73 // SessionRestoreImpl ---------------------------------------------------------
72 74
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 content::Source<Browser>(browser_)); 151 content::Source<Browser>(browser_));
150 } 152 }
151 153
152 return browser_; 154 return browser_;
153 } 155 }
154 156
155 // Restore window(s) from a foreign session. Returns newly created Browsers. 157 // Restore window(s) from a foreign session. Returns newly created Browsers.
156 std::vector<Browser*> RestoreForeignSession( 158 std::vector<Browser*> RestoreForeignSession(
157 std::vector<const sessions::SessionWindow*>::const_iterator begin, 159 std::vector<const sessions::SessionWindow*>::const_iterator begin,
158 std::vector<const sessions::SessionWindow*>::const_iterator end) { 160 std::vector<const sessions::SessionWindow*>::const_iterator end) {
159 StartTabCreation();
160 std::vector<Browser*> browsers; 161 std::vector<Browser*> browsers;
161 std::vector<WebContents*> created_contents; 162 std::vector<RestoredTab> created_contents;
162 // Create a browser instance to put the restored tabs in. 163 // Create a browser instance to put the restored tabs in.
163 for (std::vector<const sessions::SessionWindow*>::const_iterator i = begin; 164 for (std::vector<const sessions::SessionWindow*>::const_iterator i = begin;
164 i != end; ++i) { 165 i != end; ++i) {
165 Browser* browser = 166 Browser* browser =
166 CreateRestoredBrowser(BrowserTypeForWindowType((*i)->type), 167 CreateRestoredBrowser(BrowserTypeForWindowType((*i)->type),
167 (*i)->bounds, (*i)->show_state, (*i)->app_name); 168 (*i)->bounds, (*i)->show_state, (*i)->app_name);
168 browsers.push_back(browser); 169 browsers.push_back(browser);
169 170
170 // Restore and show the browser. 171 // Restore and show the browser.
171 const int initial_tab_count = 0; 172 const int initial_tab_count = 0;
172 int selected_tab_index = 173 int selected_tab_index =
173 std::max(0, std::min((*i)->selected_tab_index, 174 std::max(0, std::min((*i)->selected_tab_index,
174 static_cast<int>((*i)->tabs.size()) - 1)); 175 static_cast<int>((*i)->tabs.size()) - 1));
175 RestoreTabsToBrowser(*(*i), browser, initial_tab_count, 176 RestoreTabsToBrowser(*(*i), browser, initial_tab_count,
176 selected_tab_index, &created_contents); 177 selected_tab_index, &created_contents);
177 NotifySessionServiceOfRestoredTabs(browser, initial_tab_count); 178 NotifySessionServiceOfRestoredTabs(browser, initial_tab_count);
178 } 179 }
179 180
180 // Always create in a new window. 181 // Always create in a new window.
181 FinishedTabCreation(true, true); 182 FinishedTabCreation(true, true, created_contents);
182 183
183 on_session_restored_callbacks_->Notify( 184 on_session_restored_callbacks_->Notify(
184 static_cast<int>(created_contents.size())); 185 static_cast<int>(created_contents.size()));
185 186
186 return browsers; 187 return browsers;
187 } 188 }
188 189
189 // Restore a single tab from a foreign session. 190 // Restore a single tab from a foreign session.
190 // Opens in the tab in the last active browser, unless disposition is 191 // Opens in the tab in the last active browser, unless disposition is
191 // NEW_WINDOW, in which case the tab will be opened in a new browser. Returns 192 // NEW_WINDOW, in which case the tab will be opened in a new browser. Returns
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 264
264 default: 265 default:
265 NOTREACHED(); 266 NOTREACHED();
266 break; 267 break;
267 } 268 }
268 } 269 }
269 270
270 Profile* profile() { return profile_; } 271 Profile* profile() { return profile_; }
271 272
272 private: 273 private:
273 // Invoked when beginning to create new tabs. Resets the |tab_loader_|.
274 void StartTabCreation() {
275 tab_loader_ = TabLoader::GetTabLoader(restore_started_);
276 }
277
278 // Invoked when done with creating all the tabs/browsers. 274 // Invoked when done with creating all the tabs/browsers.
279 // 275 //
280 // |created_tabbed_browser| indicates whether a tabbed browser was created, 276 // |created_tabbed_browser| indicates whether a tabbed browser was created,
281 // or we used an existing tabbed browser. 277 // or we used an existing tabbed browser.
282 // 278 //
283 // If successful, this begins loading tabs and deletes itself when all tabs 279 // If successful, this begins loading tabs and deletes itself when all tabs
284 // have been loaded. 280 // have been loaded.
285 // 281 //
286 // Returns the Browser that was created, if any. 282 // Returns the Browser that was created, if any.
287 Browser* FinishedTabCreation(bool succeeded, bool created_tabbed_browser) { 283 Browser* FinishedTabCreation(
284 bool succeeded,
285 bool created_tabbed_browser,
286 const std::vector<RestoredTab>& contents_created) {
288 Browser* browser = nullptr; 287 Browser* browser = nullptr;
289 if (!created_tabbed_browser && always_create_tabbed_browser_) { 288 if (!created_tabbed_browser && always_create_tabbed_browser_) {
290 browser = 289 browser =
291 new Browser(Browser::CreateParams(profile_, host_desktop_type_)); 290 new Browser(Browser::CreateParams(profile_, host_desktop_type_));
292 if (urls_to_open_.empty()) { 291 if (urls_to_open_.empty()) {
293 // No tab browsers were created and no URLs were supplied on the command 292 // No tab browsers were created and no URLs were supplied on the command
294 // line. Open the new tab page. 293 // line. Open the new tab page.
295 urls_to_open_.push_back(GURL(chrome::kChromeUINewTabURL)); 294 urls_to_open_.push_back(GURL(chrome::kChromeUINewTabURL));
296 } 295 }
297 AppendURLsToBrowser(browser, urls_to_open_); 296 AppendURLsToBrowser(browser, urls_to_open_);
298 browser->window()->Show(); 297 browser->window()->Show();
299 } 298 }
300 299
301 if (succeeded) { 300 if (succeeded) {
302 DCHECK(tab_loader_.get()); 301 // Start Loading tabs.
303 // TabLoader deletes itself when done loading. 302 SessionRestoreDelegate::RestoreTabs(contents_created, restore_started_);
304 tab_loader_->StartLoading();
305 tab_loader_ = nullptr;
306 } 303 }
307 304
308 if (!synchronous_) { 305 if (!synchronous_) {
309 // If we're not synchronous we need to delete ourself. 306 // If we're not synchronous we need to delete ourself.
310 // NOTE: we must use DeleteLater here as most likely we're in a callback 307 // NOTE: we must use DeleteLater here as most likely we're in a callback
311 // from the history service which doesn't deal well with deleting the 308 // from the history service which doesn't deal well with deleting the
312 // object it is notifying. 309 // object it is notifying.
313 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 310 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
314 311
315 // The delete may take a while and at this point we no longer care about 312 // The delete may take a while and at this point we no longer care about
(...skipping 30 matching lines...) Expand all
346 quit_closure_for_sync_restore_.Run(); 343 quit_closure_for_sync_restore_.Run();
347 return; 344 return;
348 } 345 }
349 346
350 ProcessSessionWindowsAndNotify(&windows.get(), active_window_id); 347 ProcessSessionWindowsAndNotify(&windows.get(), active_window_id);
351 } 348 }
352 349
353 Browser* ProcessSessionWindowsAndNotify( 350 Browser* ProcessSessionWindowsAndNotify(
354 std::vector<sessions::SessionWindow*>* windows, 351 std::vector<sessions::SessionWindow*>* windows,
355 SessionID::id_type active_window_id) { 352 SessionID::id_type active_window_id) {
356 std::vector<WebContents*> contents; 353 std::vector<RestoredTab> contents;
357 Browser* result = 354 Browser* result =
358 ProcessSessionWindows(windows, active_window_id, &contents); 355 ProcessSessionWindows(windows, active_window_id, &contents);
359 on_session_restored_callbacks_->Notify(static_cast<int>(contents.size())); 356 on_session_restored_callbacks_->Notify(static_cast<int>(contents.size()));
360 return result; 357 return result;
361 } 358 }
362 359
363 Browser* ProcessSessionWindows(std::vector<sessions::SessionWindow*>* windows, 360 Browser* ProcessSessionWindows(std::vector<sessions::SessionWindow*>* windows,
364 SessionID::id_type active_window_id, 361 SessionID::id_type active_window_id,
365 std::vector<WebContents*>* created_contents) { 362 std::vector<RestoredTab>* created_contents) {
366 DVLOG(1) << "ProcessSessionWindows " << windows->size(); 363 DVLOG(1) << "ProcessSessionWindows " << windows->size();
367 base::TimeDelta time_to_process_sessions = 364 base::TimeDelta time_to_process_sessions =
368 base::TimeTicks::Now() - restore_started_; 365 base::TimeTicks::Now() - restore_started_;
369 UMA_HISTOGRAM_CUSTOM_TIMES("SessionRestore.TimeToProcessSessions", 366 UMA_HISTOGRAM_CUSTOM_TIMES("SessionRestore.TimeToProcessSessions",
370 time_to_process_sessions, 367 time_to_process_sessions,
371 base::TimeDelta::FromMilliseconds(10), 368 base::TimeDelta::FromMilliseconds(10),
372 base::TimeDelta::FromSeconds(1000), 100); 369 base::TimeDelta::FromSeconds(1000), 100);
373 370
374 if (windows->empty()) { 371 if (windows->empty()) {
375 // Restore was unsuccessful. The DOM storage system can also delete its 372 // Restore was unsuccessful. The DOM storage system can also delete its
376 // data, since no session restore will happen at a later point in time. 373 // data, since no session restore will happen at a later point in time.
377 content::BrowserContext::GetDefaultStoragePartition(profile_) 374 content::BrowserContext::GetDefaultStoragePartition(profile_)
378 ->GetDOMStorageContext() 375 ->GetDOMStorageContext()
379 ->StartScavengingUnusedSessionStorage(); 376 ->StartScavengingUnusedSessionStorage();
380 return FinishedTabCreation(false, false); 377 return FinishedTabCreation(false, false, *created_contents);
381 } 378 }
382 379
383 #if defined(OS_CHROMEOS) 380 #if defined(OS_CHROMEOS)
384 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( 381 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker(
385 "SessionRestore-CreatingTabs-Start", false); 382 "SessionRestore-CreatingTabs-Start", false);
386 #endif 383 #endif
387 StartTabCreation();
388 384
389 // After the for loop this contains the last TABBED_BROWSER. Is null if no 385 // After the for loop this contains the last TABBED_BROWSER. Is null if no
390 // tabbed browsers exist. 386 // tabbed browsers exist.
391 Browser* last_browser = nullptr; 387 Browser* last_browser = nullptr;
392 bool has_tabbed_browser = false; 388 bool has_tabbed_browser = false;
393 389
394 // After the for loop, this contains the browser to activate, if one of the 390 // After the for loop, this contains the browser to activate, if one of the
395 // windows has the same id as specified in active_window_id. 391 // windows has the same id as specified in active_window_id.
396 Browser* browser_to_activate = nullptr; 392 Browser* browser_to_activate = nullptr;
397 393
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 #if defined(OS_CHROMEOS) 466 #if defined(OS_CHROMEOS)
471 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( 467 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker(
472 "SessionRestore-CreatingTabs-End", false); 468 "SessionRestore-CreatingTabs-End", false);
473 #endif 469 #endif
474 if (browser_to_activate) 470 if (browser_to_activate)
475 browser_to_activate->window()->Activate(); 471 browser_to_activate->window()->Activate();
476 472
477 // If last_browser is NULL and urls_to_open_ is non-empty, 473 // If last_browser is NULL and urls_to_open_ is non-empty,
478 // FinishedTabCreation will create a new TabbedBrowser and add the urls to 474 // FinishedTabCreation will create a new TabbedBrowser and add the urls to
479 // it. 475 // it.
480 Browser* finished_browser = FinishedTabCreation(true, has_tabbed_browser); 476 Browser* finished_browser =
477 FinishedTabCreation(true, has_tabbed_browser, *created_contents);
481 if (finished_browser) 478 if (finished_browser)
482 last_browser = finished_browser; 479 last_browser = finished_browser;
483 480
484 // sessionStorages needed for the session restore have now been recreated 481 // sessionStorages needed for the session restore have now been recreated
485 // by RestoreTab. Now it's safe for the DOM storage system to start 482 // by RestoreTab. Now it's safe for the DOM storage system to start
486 // deleting leftover data. 483 // deleting leftover data.
487 content::BrowserContext::GetDefaultStoragePartition(profile_) 484 content::BrowserContext::GetDefaultStoragePartition(profile_)
488 ->GetDOMStorageContext() 485 ->GetDOMStorageContext()
489 ->StartScavengingUnusedSessionStorage(); 486 ->StartScavengingUnusedSessionStorage();
490 return last_browser; 487 return last_browser;
(...skipping 19 matching lines...) Expand all
510 } 507 }
511 508
512 // Adds the tabs from |window| to |browser|. Normal tabs go after the existing 509 // Adds the tabs from |window| to |browser|. Normal tabs go after the existing
513 // tabs but pinned tabs will be pushed in front. 510 // tabs but pinned tabs will be pushed in front.
514 // If there are no existing tabs, the tab at |selected_tab_index| will be 511 // If there are no existing tabs, the tab at |selected_tab_index| will be
515 // selected. Otherwise, the tab selection will remain untouched. 512 // selected. Otherwise, the tab selection will remain untouched.
516 void RestoreTabsToBrowser(const sessions::SessionWindow& window, 513 void RestoreTabsToBrowser(const sessions::SessionWindow& window,
517 Browser* browser, 514 Browser* browser,
518 int initial_tab_count, 515 int initial_tab_count,
519 int selected_tab_index, 516 int selected_tab_index,
520 std::vector<WebContents*>* created_contents) { 517 std::vector<RestoredTab>* created_contents) {
521 DVLOG(1) << "RestoreTabsToBrowser " << window.tabs.size(); 518 DVLOG(1) << "RestoreTabsToBrowser " << window.tabs.size();
522 DCHECK(!window.tabs.empty()); 519 DCHECK(!window.tabs.empty());
523 if (initial_tab_count == 0) { 520 if (initial_tab_count == 0) {
524 for (int i = 0; i < static_cast<int>(window.tabs.size()); ++i) { 521 for (int i = 0; i < static_cast<int>(window.tabs.size()); ++i) {
525 const sessions::SessionTab& tab = *(window.tabs[i]); 522 const sessions::SessionTab& tab = *(window.tabs[i]);
526 523
527 // Loads are scheduled for each restored tab unless the tab is going to 524 // Loads are scheduled for each restored tab unless the tab is going to
528 // be selected as ShowBrowser() will load the selected tab. 525 // be selected as ShowBrowser() will load the selected tab.
529 bool is_selected_tab = (i == selected_tab_index); 526 bool is_selected_tab = (i == selected_tab_index);
530 WebContents* restored_tab = 527 WebContents* contents = RestoreTab(tab, i, browser, is_selected_tab);
531 RestoreTab(tab, i, browser, is_selected_tab);
532 528
533 // RestoreTab can return nullptr if |tab| doesn't have valid data. 529 // RestoreTab can return nullptr if |tab| doesn't have valid data.
534 if (!restored_tab) 530 if (!contents)
535 continue; 531 continue;
536 532
533 RestoredTab restored_tab;
534 restored_tab.contents = contents;
535 restored_tab.is_active = is_selected_tab;
537 created_contents->push_back(restored_tab); 536 created_contents->push_back(restored_tab);
538 537
539 // If this isn't the selected tab, there's nothing else to do. 538 // If this isn't the selected tab, there's nothing else to do.
540 if (!is_selected_tab) 539 if (!is_selected_tab)
541 continue; 540 continue;
542 541
543 ShowBrowser(browser, browser->tab_strip_model()->GetIndexOfWebContents( 542 ShowBrowser(browser, browser->tab_strip_model()->GetIndexOfWebContents(
544 restored_tab)); 543 contents));
545 // TODO(sky): remove. For debugging 368236. 544 // TODO(sky): remove. For debugging 368236.
546 CHECK_EQ(browser->tab_strip_model()->GetActiveWebContents(), 545 CHECK_EQ(browser->tab_strip_model()->GetActiveWebContents(), contents);
547 restored_tab);
548 tab_loader_->TabIsLoading(&browser->tab_strip_model()
549 ->GetActiveWebContents()
550 ->GetController());
551 } 546 }
552 } else { 547 } else {
553 // If the browser already has tabs, we want to restore the new ones after 548 // If the browser already has tabs, we want to restore the new ones after
554 // the existing ones. E.g. this happens in Win8 Metro where we merge 549 // the existing ones. E.g. this happens in Win8 Metro where we merge
555 // windows or when launching a hosted app from the app launcher. 550 // windows or when launching a hosted app from the app launcher.
556 int tab_index_offset = initial_tab_count; 551 int tab_index_offset = initial_tab_count;
557 for (int i = 0; i < static_cast<int>(window.tabs.size()); ++i) { 552 for (int i = 0; i < static_cast<int>(window.tabs.size()); ++i) {
558 const sessions::SessionTab& tab = *(window.tabs[i]); 553 const sessions::SessionTab& tab = *(window.tabs[i]);
559 // Always schedule loads as we will not be calling ShowBrowser(). 554 // Always schedule loads as we will not be calling ShowBrowser().
560 WebContents* contents = 555 WebContents* contents =
561 RestoreTab(tab, tab_index_offset + i, browser, false); 556 RestoreTab(tab, tab_index_offset + i, browser, false);
562 if (contents) 557 if (contents) {
563 created_contents->push_back(contents); 558 RestoredTab restored_tab;
559 restored_tab.contents = contents;
560 restored_tab.is_active = false;
561 created_contents->push_back(restored_tab);
562 }
564 } 563 }
565 } 564 }
566 } 565 }
567 566
568 // |tab_index| is ignored for pinned tabs which will always be pushed behind 567 // |tab_index| is ignored for pinned tabs which will always be pushed behind
569 // the last existing pinned tab. 568 // the last existing pinned tab.
570 // |tab_loader_| will schedule this tab for loading if |is_selected_tab| is 569 // |tab_loader_| will schedule this tab for loading if |is_selected_tab| is
571 // false. 570 // false.
572 WebContents* RestoreTab(const sessions::SessionTab& tab, 571 WebContents* RestoreTab(const sessions::SessionTab& tab,
573 const int tab_index, 572 const int tab_index,
(...skipping 23 matching lines...) Expand all
597 WebContents* web_contents = chrome::AddRestoredTab( 596 WebContents* web_contents = chrome::AddRestoredTab(
598 browser, tab.navigations, tab_index, selected_index, 597 browser, tab.navigations, tab_index, selected_index,
599 tab.extension_app_id, 598 tab.extension_app_id,
600 false, // select 599 false, // select
601 tab.pinned, true, session_storage_namespace.get(), 600 tab.pinned, true, session_storage_namespace.get(),
602 tab.user_agent_override); 601 tab.user_agent_override);
603 // Regression check: check that the tab didn't start loading right away. The 602 // Regression check: check that the tab didn't start loading right away. The
604 // focused tab will be loaded by Browser, and TabLoader will load the rest. 603 // focused tab will be loaded by Browser, and TabLoader will load the rest.
605 DCHECK(web_contents->GetController().NeedsReload()); 604 DCHECK(web_contents->GetController().NeedsReload());
606 605
607 if (!is_selected_tab)
608 tab_loader_->ScheduleLoad(&web_contents->GetController());
609 return web_contents; 606 return web_contents;
610 } 607 }
611 608
612 Browser* CreateRestoredBrowser(Browser::Type type, 609 Browser* CreateRestoredBrowser(Browser::Type type,
613 gfx::Rect bounds, 610 gfx::Rect bounds,
614 ui::WindowShowState show_state, 611 ui::WindowShowState show_state,
615 const std::string& app_name) { 612 const std::string& app_name) {
616 Browser::CreateParams params(type, profile_, host_desktop_type_); 613 Browser::CreateParams params(type, profile_, host_desktop_type_);
617 if (!app_name.empty()) { 614 if (!app_name.empty()) {
618 const bool trusted_source = true; // We only store trusted app windows. 615 const bool trusted_source = true; // We only store trusted app windows.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 // static 839 // static
843 SessionRestore::CallbackSubscription 840 SessionRestore::CallbackSubscription
844 SessionRestore::RegisterOnSessionRestoredCallback( 841 SessionRestore::RegisterOnSessionRestoredCallback(
845 const base::Callback<void(int)>& callback) { 842 const base::Callback<void(int)>& callback) {
846 return on_session_restored_callbacks()->Add(callback); 843 return on_session_restored_callbacks()->Add(callback);
847 } 844 }
848 845
849 // static 846 // static
850 base::CallbackList<void(int)>* 847 base::CallbackList<void(int)>*
851 SessionRestore::on_session_restored_callbacks_ = nullptr; 848 SessionRestore::on_session_restored_callbacks_ = nullptr;
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sessions/session_restore_delegate.h » ('j') | chrome/browser/sessions/tab_loader.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698