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

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

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

Powered by Google App Engine
This is Rietveld 408576698