| 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/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> |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 Browser* Restore() { | 530 Browser* Restore() { |
| 531 SessionService* session_service = | 531 SessionService* session_service = |
| 532 SessionServiceFactory::GetForProfile(profile_); | 532 SessionServiceFactory::GetForProfile(profile_); |
| 533 DCHECK(session_service); | 533 DCHECK(session_service); |
| 534 session_service->GetLastSession( | 534 session_service->GetLastSession( |
| 535 base::Bind(&SessionRestoreImpl::OnGotSession, base::Unretained(this)), | 535 base::Bind(&SessionRestoreImpl::OnGotSession, base::Unretained(this)), |
| 536 &cancelable_task_tracker_); | 536 &cancelable_task_tracker_); |
| 537 | 537 |
| 538 if (synchronous_) { | 538 if (synchronous_) { |
| 539 { | 539 { |
| 540 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); | 540 base::MessageLoop::ScopedNestableTaskAllower allow( |
| 541 MessageLoop::current()->Run(); | 541 base::MessageLoop::current()); |
| 542 base::MessageLoop::current()->Run(); |
| 542 } | 543 } |
| 543 Browser* browser = ProcessSessionWindows(&windows_, active_window_id_); | 544 Browser* browser = ProcessSessionWindows(&windows_, active_window_id_); |
| 544 delete this; | 545 delete this; |
| 545 content::NotificationService::current()->Notify( | 546 content::NotificationService::current()->Notify( |
| 546 chrome::NOTIFICATION_SESSION_RESTORE_DONE, | 547 chrome::NOTIFICATION_SESSION_RESTORE_DONE, |
| 547 content::NotificationService::AllSources(), | 548 content::NotificationService::AllSources(), |
| 548 content::NotificationService::NoDetails()); | 549 content::NotificationService::NoDetails()); |
| 549 return browser; | 550 return browser; |
| 550 } | 551 } |
| 551 | 552 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 // TabLoader deletes itself when done loading. | 709 // TabLoader deletes itself when done loading. |
| 709 tab_loader_->StartLoading(); | 710 tab_loader_->StartLoading(); |
| 710 tab_loader_ = NULL; | 711 tab_loader_ = NULL; |
| 711 } | 712 } |
| 712 | 713 |
| 713 if (!synchronous_) { | 714 if (!synchronous_) { |
| 714 // If we're not synchronous we need to delete ourself. | 715 // If we're not synchronous we need to delete ourself. |
| 715 // NOTE: we must use DeleteLater here as most likely we're in a callback | 716 // NOTE: we must use DeleteLater here as most likely we're in a callback |
| 716 // from the history service which doesn't deal well with deleting the | 717 // from the history service which doesn't deal well with deleting the |
| 717 // object it is notifying. | 718 // object it is notifying. |
| 718 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 719 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 719 | 720 |
| 720 // The delete may take a while and at this point we no longer care about | 721 // The delete may take a while and at this point we no longer care about |
| 721 // if the browser is deleted. Don't listen to anything. This avoid a | 722 // if the browser is deleted. Don't listen to anything. This avoid a |
| 722 // possible double delete too (if browser is closed before DeleteSoon() is | 723 // possible double delete too (if browser is closed before DeleteSoon() is |
| 723 // processed). | 724 // processed). |
| 724 registrar_.RemoveAll(); | 725 registrar_.RemoveAll(); |
| 725 } | 726 } |
| 726 | 727 |
| 727 #if defined(OS_CHROMEOS) | 728 #if defined(OS_CHROMEOS) |
| 728 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( | 729 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 742 base::TimeDelta::FromSeconds(1000), | 743 base::TimeDelta::FromSeconds(1000), |
| 743 100); | 744 100); |
| 744 #if defined(OS_CHROMEOS) | 745 #if defined(OS_CHROMEOS) |
| 745 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( | 746 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( |
| 746 "SessionRestore-GotSession", false); | 747 "SessionRestore-GotSession", false); |
| 747 #endif | 748 #endif |
| 748 if (synchronous_) { | 749 if (synchronous_) { |
| 749 // See comment above windows_ as to why we don't process immediately. | 750 // See comment above windows_ as to why we don't process immediately. |
| 750 windows_.swap(windows.get()); | 751 windows_.swap(windows.get()); |
| 751 active_window_id_ = active_window_id; | 752 active_window_id_ = active_window_id; |
| 752 MessageLoop::current()->QuitNow(); | 753 base::MessageLoop::current()->QuitNow(); |
| 753 return; | 754 return; |
| 754 } | 755 } |
| 755 | 756 |
| 756 ProcessSessionWindows(&windows.get(), active_window_id); | 757 ProcessSessionWindows(&windows.get(), active_window_id); |
| 757 } | 758 } |
| 758 | 759 |
| 759 Browser* ProcessSessionWindows(std::vector<SessionWindow*>* windows, | 760 Browser* ProcessSessionWindows(std::vector<SessionWindow*>* windows, |
| 760 SessionID::id_type active_window_id) { | 761 SessionID::id_type active_window_id) { |
| 761 VLOG(1) << "ProcessSessionWindows " << windows->size(); | 762 VLOG(1) << "ProcessSessionWindows " << windows->size(); |
| 762 base::TimeDelta time_to_process_sessions = | 763 base::TimeDelta time_to_process_sessions = |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 if (!active_session_restorers) | 1257 if (!active_session_restorers) |
| 1257 return false; | 1258 return false; |
| 1258 for (std::set<SessionRestoreImpl*>::const_iterator it = | 1259 for (std::set<SessionRestoreImpl*>::const_iterator it = |
| 1259 active_session_restorers->begin(); | 1260 active_session_restorers->begin(); |
| 1260 it != active_session_restorers->end(); ++it) { | 1261 it != active_session_restorers->end(); ++it) { |
| 1261 if ((*it)->synchronous()) | 1262 if ((*it)->synchronous()) |
| 1262 return true; | 1263 return true; |
| 1263 } | 1264 } |
| 1264 return false; | 1265 return false; |
| 1265 } | 1266 } |
| OLD | NEW |