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

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

Issue 7274033: Fixes race condition that could lead to premature shutdown. When (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove FLAKY_ from test Created 9 years, 5 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
« no previous file with comments | « chrome/browser/sessions/session_restore.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/stl_util-inl.h" 16 #include "base/stl_util-inl.h"
17 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
18 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/sessions/session_service.h" 21 #include "chrome/browser/sessions/session_service.h"
21 #include "chrome/browser/sessions/session_service_factory.h" 22 #include "chrome/browser/sessions/session_service_factory.h"
22 #include "chrome/browser/sessions/session_types.h" 23 #include "chrome/browser/sessions/session_types.h"
23 #include "chrome/browser/tabs/tab_strip_model.h" 24 #include "chrome/browser/tabs/tab_strip_model.h"
24 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_list.h" 26 #include "chrome/browser/ui/browser_list.h"
26 #include "chrome/browser/ui/browser_navigator.h" 27 #include "chrome/browser/ui/browser_navigator.h"
27 #include "chrome/browser/ui/browser_window.h" 28 #include "chrome/browser/ui/browser_window.h"
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 bool clobber_existing_window, 415 bool clobber_existing_window,
415 bool always_create_tabbed_browser, 416 bool always_create_tabbed_browser,
416 const std::vector<GURL>& urls_to_open) 417 const std::vector<GURL>& urls_to_open)
417 : profile_(profile), 418 : profile_(profile),
418 browser_(browser), 419 browser_(browser),
419 synchronous_(synchronous), 420 synchronous_(synchronous),
420 clobber_existing_window_(clobber_existing_window), 421 clobber_existing_window_(clobber_existing_window),
421 always_create_tabbed_browser_(always_create_tabbed_browser), 422 always_create_tabbed_browser_(always_create_tabbed_browser),
422 urls_to_open_(urls_to_open), 423 urls_to_open_(urls_to_open),
423 restore_started_(base::TimeTicks::Now()) { 424 restore_started_(base::TimeTicks::Now()) {
425 // When asynchronous its possible for there to be no windows. To make sure
426 // Chrome doesn't prematurely exit AddRef the process. We'll release in the
427 // destructor when restore is done.
428 g_browser_process->AddRefModule();
424 } 429 }
425 430
426 Browser* Restore() { 431 Browser* Restore() {
427 SessionService* session_service = 432 SessionService* session_service =
428 SessionServiceFactory::GetForProfile(profile_); 433 SessionServiceFactory::GetForProfile(profile_);
429 DCHECK(session_service); 434 DCHECK(session_service);
430 SessionService::SessionCallback* callback = 435 SessionService::SessionCallback* callback =
431 NewCallback(this, &SessionRestoreImpl::OnGotSession); 436 NewCallback(this, &SessionRestoreImpl::OnGotSession);
432 session_service->GetLastSession(&request_consumer_, callback); 437 session_service->GetLastSession(&request_consumer_, callback);
433 438
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 browser_ ? browser_ : BrowserList::GetLastActiveWithProfile(profile_); 489 browser_ ? browser_ : BrowserList::GetLastActiveWithProfile(profile_);
485 RestoreTab(tab, current_browser->tab_count(), current_browser, true); 490 RestoreTab(tab, current_browser->tab_count(), current_browser, true);
486 NotifySessionServiceOfRestoredTabs(current_browser, 491 NotifySessionServiceOfRestoredTabs(current_browser,
487 current_browser->tab_count()); 492 current_browser->tab_count());
488 FinishedTabCreation(true, true); 493 FinishedTabCreation(true, true);
489 } 494 }
490 495
491 ~SessionRestoreImpl() { 496 ~SessionRestoreImpl() {
492 STLDeleteElements(&windows_); 497 STLDeleteElements(&windows_);
493 restoring = false; 498 restoring = false;
499 g_browser_process->ReleaseModule();
494 } 500 }
495 501
496 virtual void Observe(NotificationType type, 502 virtual void Observe(NotificationType type,
497 const NotificationSource& source, 503 const NotificationSource& source,
498 const NotificationDetails& details) { 504 const NotificationDetails& details) {
499 switch (type.value) { 505 switch (type.value) {
500 case NotificationType::BROWSER_CLOSED: 506 case NotificationType::BROWSER_CLOSED:
501 delete this; 507 delete this;
502 return; 508 return;
503 509
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 Browser* SessionRestore::RestoreSessionSynchronously( 849 Browser* SessionRestore::RestoreSessionSynchronously(
844 Profile* profile, 850 Profile* profile,
845 const std::vector<GURL>& urls_to_open) { 851 const std::vector<GURL>& urls_to_open) {
846 return Restore(profile, NULL, true, false, true, urls_to_open); 852 return Restore(profile, NULL, true, false, true, urls_to_open);
847 } 853 }
848 854
849 // static 855 // static
850 bool SessionRestore::IsRestoring() { 856 bool SessionRestore::IsRestoring() {
851 return restoring; 857 return restoring;
852 } 858 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698