| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
| 17 #include "base/callback.h" | 17 #include "base/callback.h" |
| 18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| 19 #include "base/debug/alias.h" | 19 #include "base/debug/alias.h" |
| 20 #include "base/location.h" |
| 20 #include "base/macros.h" | 21 #include "base/macros.h" |
| 21 #include "base/memory/scoped_vector.h" | 22 #include "base/memory/scoped_vector.h" |
| 22 #include "base/metrics/field_trial.h" | 23 #include "base/metrics/field_trial.h" |
| 23 #include "base/metrics/histogram.h" | 24 #include "base/metrics/histogram.h" |
| 24 #include "base/run_loop.h" | 25 #include "base/run_loop.h" |
| 26 #include "base/single_thread_task_runner.h" |
| 25 #include "base/stl_util.h" | 27 #include "base/stl_util.h" |
| 26 #include "base/task/cancelable_task_tracker.h" | 28 #include "base/task/cancelable_task_tracker.h" |
| 29 #include "base/threading/thread_task_runner_handle.h" |
| 27 #include "build/build_config.h" | 30 #include "build/build_config.h" |
| 28 #include "chrome/browser/browser_process.h" | 31 #include "chrome/browser/browser_process.h" |
| 29 #include "chrome/browser/chrome_notification_types.h" | 32 #include "chrome/browser/chrome_notification_types.h" |
| 30 #include "chrome/browser/lifetime/keep_alive_types.h" | 33 #include "chrome/browser/lifetime/keep_alive_types.h" |
| 31 #include "chrome/browser/lifetime/scoped_keep_alive.h" | 34 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
| 32 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
| 33 #include "chrome/browser/search/search.h" | 36 #include "chrome/browser/search/search.h" |
| 34 #include "chrome/browser/sessions/session_restore_delegate.h" | 37 #include "chrome/browser/sessions/session_restore_delegate.h" |
| 35 #include "chrome/browser/sessions/session_service.h" | 38 #include "chrome/browser/sessions/session_service.h" |
| 36 #include "chrome/browser/sessions/session_service_factory.h" | 39 #include "chrome/browser/sessions/session_service_factory.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 // them. | 300 // them. |
| 298 std::stable_sort(contents_created->begin(), contents_created->end()); | 301 std::stable_sort(contents_created->begin(), contents_created->end()); |
| 299 SessionRestoreDelegate::RestoreTabs(*contents_created, restore_started_); | 302 SessionRestoreDelegate::RestoreTabs(*contents_created, restore_started_); |
| 300 } | 303 } |
| 301 | 304 |
| 302 if (!synchronous_) { | 305 if (!synchronous_) { |
| 303 // If we're not synchronous we need to delete ourself. | 306 // If we're not synchronous we need to delete ourself. |
| 304 // 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 |
| 305 // 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 |
| 306 // object it is notifying. | 309 // object it is notifying. |
| 307 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 310 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 308 | 311 |
| 309 // 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 |
| 310 // if the browser is deleted. Don't listen to anything. This avoid a | 313 // if the browser is deleted. Don't listen to anything. This avoid a |
| 311 // possible double delete too (if browser is closed before DeleteSoon() is | 314 // possible double delete too (if browser is closed before DeleteSoon() is |
| 312 // processed). | 315 // processed). |
| 313 registrar_.RemoveAll(); | 316 registrar_.RemoveAll(); |
| 314 } | 317 } |
| 315 | 318 |
| 316 #if defined(OS_CHROMEOS) | 319 #if defined(OS_CHROMEOS) |
| 317 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker("SessionRestore-End", | 320 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker("SessionRestore-End", |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 // static | 838 // static |
| 836 SessionRestore::CallbackSubscription | 839 SessionRestore::CallbackSubscription |
| 837 SessionRestore::RegisterOnSessionRestoredCallback( | 840 SessionRestore::RegisterOnSessionRestoredCallback( |
| 838 const base::Callback<void(int)>& callback) { | 841 const base::Callback<void(int)>& callback) { |
| 839 return on_session_restored_callbacks()->Add(callback); | 842 return on_session_restored_callbacks()->Add(callback); |
| 840 } | 843 } |
| 841 | 844 |
| 842 // static | 845 // static |
| 843 base::CallbackList<void(int)>* | 846 base::CallbackList<void(int)>* |
| 844 SessionRestore::on_session_restored_callbacks_ = nullptr; | 847 SessionRestore::on_session_restored_callbacks_ = nullptr; |
| OLD | NEW |