| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 | 331 |
| 332 if (!tabs_to_load_.empty()) | 332 if (!tabs_to_load_.empty()) |
| 333 StartTimer(); | 333 StartTimer(); |
| 334 | 334 |
| 335 // When the session restore is done synchronously, notification is sent from | 335 // When the session restore is done synchronously, notification is sent from |
| 336 // SessionRestoreImpl::Restore . | 336 // SessionRestoreImpl::Restore . |
| 337 if (tabs_to_load_.empty() && !SessionRestore::IsRestoringSynchronously()) { | 337 if (tabs_to_load_.empty() && !SessionRestore::IsRestoringSynchronously()) { |
| 338 on_session_restored_callbacks_->Notify(); | 338 on_session_restored_callbacks_->Notify(tab_count_); |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 void TabLoader::StartTimer() { | 342 void TabLoader::StartTimer() { |
| 343 force_load_timer_.Stop(); | 343 force_load_timer_.Stop(); |
| 344 force_load_timer_.Start(FROM_HERE, | 344 force_load_timer_.Start(FROM_HERE, |
| 345 delegate_->GetTimeoutBeforeLoadingNextTab() * | 345 delegate_->GetTimeoutBeforeLoadingNextTab() * |
| 346 force_load_delay_multiplier_, | 346 force_load_delay_multiplier_, |
| 347 this, &TabLoader::ForceLoadTimerFired); | 347 this, &TabLoader::ForceLoadTimerFired); |
| 348 } | 348 } |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 | 634 |
| 635 if (synchronous_) { | 635 if (synchronous_) { |
| 636 { | 636 { |
| 637 base::MessageLoop::ScopedNestableTaskAllower allow( | 637 base::MessageLoop::ScopedNestableTaskAllower allow( |
| 638 base::MessageLoop::current()); | 638 base::MessageLoop::current()); |
| 639 base::RunLoop loop; | 639 base::RunLoop loop; |
| 640 quit_closure_for_sync_restore_ = loop.QuitClosure(); | 640 quit_closure_for_sync_restore_ = loop.QuitClosure(); |
| 641 loop.Run(); | 641 loop.Run(); |
| 642 quit_closure_for_sync_restore_ = base::Closure(); | 642 quit_closure_for_sync_restore_ = base::Closure(); |
| 643 } | 643 } |
| 644 // Count the total number of tabs in |windows_|. |
| 645 int total_num_tabs = 0; |
| 646 for (int i = 0; i < static_cast<int>(windows_.size()); ++i) |
| 647 total_num_tabs += windows_[i]->tabs.size(); |
| 648 |
| 644 Browser* browser = ProcessSessionWindows(&windows_, active_window_id_); | 649 Browser* browser = ProcessSessionWindows(&windows_, active_window_id_); |
| 645 on_session_restored_callbacks_->Notify(); | 650 on_session_restored_callbacks_->Notify(total_num_tabs); |
| 646 delete this; | 651 delete this; |
| 647 return browser; | 652 return browser; |
| 648 } | 653 } |
| 649 | 654 |
| 650 if (browser_) { | 655 if (browser_) { |
| 651 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, | 656 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, |
| 652 content::Source<Browser>(browser_)); | 657 content::Source<Browser>(browser_)); |
| 653 } | 658 } |
| 654 | 659 |
| 655 return browser_; | 660 return browser_; |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1347 it != active_session_restorers->end(); ++it) { | 1352 it != active_session_restorers->end(); ++it) { |
| 1348 if ((*it)->synchronous()) | 1353 if ((*it)->synchronous()) |
| 1349 return true; | 1354 return true; |
| 1350 } | 1355 } |
| 1351 return false; | 1356 return false; |
| 1352 } | 1357 } |
| 1353 | 1358 |
| 1354 // static | 1359 // static |
| 1355 SessionRestore::CallbackSubscription | 1360 SessionRestore::CallbackSubscription |
| 1356 SessionRestore::RegisterOnSessionRestoredCallback( | 1361 SessionRestore::RegisterOnSessionRestoredCallback( |
| 1357 const base::Closure& callback) { | 1362 const base::Callback<void(int)>& callback) { |
| 1358 return on_session_restored_callbacks()->Add(callback); | 1363 return on_session_restored_callbacks()->Add(callback); |
| 1359 } | 1364 } |
| 1360 | 1365 |
| 1361 // static | 1366 // static |
| 1362 base::CallbackList<void(void)>* | 1367 base::CallbackList<void(int)>* |
| 1363 SessionRestore::on_session_restored_callbacks_ = nullptr; | 1368 SessionRestore::on_session_restored_callbacks_ = nullptr; |
| OLD | NEW |