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

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: Created 7 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 | 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // TabLoader deletes itself when done loading. 713 // TabLoader deletes itself when done loading.
713 tab_loader_->StartLoading(); 714 tab_loader_->StartLoading();
714 tab_loader_ = NULL; 715 tab_loader_ = NULL;
715 } 716 }
716 717
717 if (!synchronous_) { 718 if (!synchronous_) {
718 // If we're not synchronous we need to delete ourself. 719 // If we're not synchronous we need to delete ourself.
719 // NOTE: we must use DeleteLater here as most likely we're in a callback 720 // NOTE: we must use DeleteLater here as most likely we're in a callback
720 // from the history service which doesn't deal well with deleting the 721 // from the history service which doesn't deal well with deleting the
721 // object it is notifying. 722 // object it is notifying.
722 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 723 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
723 724
724 // The delete may take a while and at this point we no longer care about 725 // The delete may take a while and at this point we no longer care about
725 // if the browser is deleted. Don't listen to anything. This avoid a 726 // if the browser is deleted. Don't listen to anything. This avoid a
726 // possible double delete too (if browser is closed before DeleteSoon() is 727 // possible double delete too (if browser is closed before DeleteSoon() is
727 // processed). 728 // processed).
728 registrar_.RemoveAll(); 729 registrar_.RemoveAll();
729 } 730 }
730 731
731 #if defined(OS_CHROMEOS) 732 #if defined(OS_CHROMEOS)
732 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( 733 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(
(...skipping 13 matching lines...) Expand all
746 base::TimeDelta::FromSeconds(1000), 747 base::TimeDelta::FromSeconds(1000),
747 100); 748 100);
748 #if defined(OS_CHROMEOS) 749 #if defined(OS_CHROMEOS)
749 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( 750 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(
750 "SessionRestore-GotSession", false); 751 "SessionRestore-GotSession", false);
751 #endif 752 #endif
752 if (synchronous_) { 753 if (synchronous_) {
753 // See comment above windows_ as to why we don't process immediately. 754 // See comment above windows_ as to why we don't process immediately.
754 windows_.swap(windows.get()); 755 windows_.swap(windows.get());
755 active_window_id_ = active_window_id; 756 active_window_id_ = active_window_id;
756 MessageLoop::current()->QuitNow(); 757 base::MessageLoop::current()->QuitNow();
757 return; 758 return;
758 } 759 }
759 760
760 ProcessSessionWindows(&windows.get(), active_window_id); 761 ProcessSessionWindows(&windows.get(), active_window_id);
761 } 762 }
762 763
763 Browser* ProcessSessionWindows(std::vector<SessionWindow*>* windows, 764 Browser* ProcessSessionWindows(std::vector<SessionWindow*>* windows,
764 SessionID::id_type active_window_id) { 765 SessionID::id_type active_window_id) {
765 VLOG(1) << "ProcessSessionWindows " << windows->size(); 766 VLOG(1) << "ProcessSessionWindows " << windows->size();
766 base::TimeDelta time_to_process_sessions = 767 base::TimeDelta time_to_process_sessions =
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 if (!active_session_restorers) 1237 if (!active_session_restorers)
1237 return false; 1238 return false;
1238 for (std::set<SessionRestoreImpl*>::const_iterator it = 1239 for (std::set<SessionRestoreImpl*>::const_iterator it =
1239 active_session_restorers->begin(); 1240 active_session_restorers->begin();
1240 it != active_session_restorers->end(); ++it) { 1241 it != active_session_restorers->end(); ++it) {
1241 if ((*it)->synchronous()) 1242 if ((*it)->synchronous())
1242 return true; 1243 return true;
1243 } 1244 }
1244 return false; 1245 return false;
1245 } 1246 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698