| OLD | NEW |
| 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_service.h" | 5 #include "chrome/browser/sessions/session_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 const SessionID& tab_id, | 490 const SessionID& tab_id, |
| 491 base::TimeTicks last_active_time) { | 491 base::TimeTicks last_active_time) { |
| 492 if (!ShouldTrackChangesToWindow(window_id)) | 492 if (!ShouldTrackChangesToWindow(window_id)) |
| 493 return; | 493 return; |
| 494 | 494 |
| 495 ScheduleCommand( | 495 ScheduleCommand( |
| 496 sessions::CreateLastActiveTimeCommand(tab_id, last_active_time).Pass()); | 496 sessions::CreateLastActiveTimeCommand(tab_id, last_active_time).Pass()); |
| 497 } | 497 } |
| 498 | 498 |
| 499 base::CancelableTaskTracker::TaskId SessionService::GetLastSession( | 499 base::CancelableTaskTracker::TaskId SessionService::GetLastSession( |
| 500 const SessionCallback& callback, | 500 const sessions::GotLastSessionCallback& callback, |
| 501 base::CancelableTaskTracker* tracker) { | 501 base::CancelableTaskTracker* tracker) { |
| 502 // OnGotSessionCommands maps the SessionCommands to browser state, then run | 502 // OnGotSessionCommands maps the SessionCommands to browser state, then run |
| 503 // the callback. | 503 // the callback. |
| 504 return base_session_service_->ScheduleGetLastSessionCommands( | 504 return base_session_service_->ScheduleGetLastSessionCommands( |
| 505 base::Bind(&SessionService::OnGotSessionCommands, | 505 base::Bind(&SessionService::OnGotSessionCommands, |
| 506 weak_factory_.GetWeakPtr(), | 506 weak_factory_.GetWeakPtr(), |
| 507 callback), | 507 callback), |
| 508 tracker); | 508 tracker); |
| 509 } | 509 } |
| 510 | 510 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 } | 688 } |
| 689 } | 689 } |
| 690 | 690 |
| 691 void SessionService::OnBrowserSetLastActive(Browser* browser) { | 691 void SessionService::OnBrowserSetLastActive(Browser* browser) { |
| 692 if (ShouldTrackBrowser(browser)) | 692 if (ShouldTrackBrowser(browser)) |
| 693 ScheduleCommand(sessions::CreateSetActiveWindowCommand( | 693 ScheduleCommand(sessions::CreateSetActiveWindowCommand( |
| 694 browser->session_id()).Pass()); | 694 browser->session_id()).Pass()); |
| 695 } | 695 } |
| 696 | 696 |
| 697 void SessionService::OnGotSessionCommands( | 697 void SessionService::OnGotSessionCommands( |
| 698 const SessionCallback& callback, | 698 const sessions::GotLastSessionCallback& callback, |
| 699 ScopedVector<sessions::SessionCommand> commands) { | 699 ScopedVector<sessions::SessionCommand> commands) { |
| 700 ScopedVector<sessions::SessionWindow> valid_windows; | 700 ScopedVector<sessions::SessionWindow> valid_windows; |
| 701 SessionID::id_type active_window_id = 0; | 701 SessionID::id_type active_window_id = 0; |
| 702 | 702 |
| 703 sessions::RestoreSessionFromCommands( | 703 sessions::RestoreSessionFromCommands( |
| 704 commands, &valid_windows.get(), &active_window_id); | 704 commands, &valid_windows.get(), &active_window_id); |
| 705 RemoveUnusedRestoreWindows(&valid_windows.get()); | 705 RemoveUnusedRestoreWindows(&valid_windows.get()); |
| 706 | 706 |
| 707 callback.Run(valid_windows.Pass(), active_window_id); | 707 callback.Run(valid_windows.Pass(), active_window_id); |
| 708 } | 708 } |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 1106 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
| 1107 if ((*it)->profile() == profile()) | 1107 if ((*it)->profile() == profile()) |
| 1108 return; | 1108 return; |
| 1109 } | 1109 } |
| 1110 DeleteSessionOnlyData(profile()); | 1110 DeleteSessionOnlyData(profile()); |
| 1111 } | 1111 } |
| 1112 | 1112 |
| 1113 sessions::BaseSessionService* SessionService::GetBaseSessionServiceForTest() { | 1113 sessions::BaseSessionService* SessionService::GetBaseSessionServiceForTest() { |
| 1114 return base_session_service_.get(); | 1114 return base_session_service_.get(); |
| 1115 } | 1115 } |
| OLD | NEW |