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_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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 void StartLoading(); | 111 void StartLoading(); |
112 | 112 |
113 private: | 113 private: |
114 friend class base::RefCounted<TabLoader>; | 114 friend class base::RefCounted<TabLoader>; |
115 | 115 |
116 typedef std::set<NavigationController*> TabsLoading; | 116 typedef std::set<NavigationController*> TabsLoading; |
117 typedef std::list<NavigationController*> TabsToLoad; | 117 typedef std::list<NavigationController*> TabsToLoad; |
118 typedef std::set<RenderWidgetHost*> RenderWidgetHostSet; | 118 typedef std::set<RenderWidgetHost*> RenderWidgetHostSet; |
119 | 119 |
120 explicit TabLoader(base::TimeTicks restore_started); | 120 explicit TabLoader(base::TimeTicks restore_started); |
121 virtual ~TabLoader(); | 121 ~TabLoader() override; |
122 | 122 |
123 // Loads the next tab. If there are no more tabs to load this deletes itself, | 123 // Loads the next tab. If there are no more tabs to load this deletes itself, |
124 // otherwise |force_load_timer_| is restarted. | 124 // otherwise |force_load_timer_| is restarted. |
125 void LoadNextTab(); | 125 void LoadNextTab(); |
126 | 126 |
127 // NotificationObserver method. Removes the specified tab and loads the next | 127 // NotificationObserver method. Removes the specified tab and loads the next |
128 // tab. | 128 // tab. |
129 virtual void Observe(int type, | 129 void Observe(int type, |
130 const content::NotificationSource& source, | 130 const content::NotificationSource& source, |
131 const content::NotificationDetails& details) override; | 131 const content::NotificationDetails& details) override; |
132 | 132 |
133 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. | 133 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. |
134 virtual void OnConnectionTypeChanged( | 134 void OnConnectionTypeChanged( |
135 net::NetworkChangeNotifier::ConnectionType type) override; | 135 net::NetworkChangeNotifier::ConnectionType type) override; |
136 | 136 |
137 // Removes the listeners from the specified tab and removes the tab from | 137 // Removes the listeners from the specified tab and removes the tab from |
138 // the set of tabs to load and list of tabs we're waiting to get a load | 138 // the set of tabs to load and list of tabs we're waiting to get a load |
139 // from. | 139 // from. |
140 void RemoveTab(NavigationController* tab); | 140 void RemoveTab(NavigationController* tab); |
141 | 141 |
142 // Invoked from |force_load_timer_|. Doubles |force_load_delay_| and invokes | 142 // Invoked from |force_load_timer_|. Doubles |force_load_delay_| and invokes |
143 // |LoadNextTab| to load the next tab | 143 // |LoadNextTab| to load the next tab |
144 void ForceLoadTimerFired(); | 144 void ForceLoadTimerFired(); |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 } | 679 } |
680 NotifySessionServiceOfRestoredTabs(browser, | 680 NotifySessionServiceOfRestoredTabs(browser, |
681 browser->tab_strip_model()->count()); | 681 browser->tab_strip_model()->count()); |
682 | 682 |
683 // Since FinishedTabCreation() is not called here, |this| will leak if we | 683 // Since FinishedTabCreation() is not called here, |this| will leak if we |
684 // are not in sychronous mode. | 684 // are not in sychronous mode. |
685 DCHECK(synchronous_); | 685 DCHECK(synchronous_); |
686 return web_contents; | 686 return web_contents; |
687 } | 687 } |
688 | 688 |
689 virtual ~SessionRestoreImpl() { | 689 ~SessionRestoreImpl() override { |
690 STLDeleteElements(&windows_); | 690 STLDeleteElements(&windows_); |
691 | 691 |
692 active_session_restorers->erase(this); | 692 active_session_restorers->erase(this); |
693 if (active_session_restorers->empty()) { | 693 if (active_session_restorers->empty()) { |
694 delete active_session_restorers; | 694 delete active_session_restorers; |
695 active_session_restorers = NULL; | 695 active_session_restorers = NULL; |
696 } | 696 } |
697 | 697 |
698 g_browser_process->ReleaseModule(); | 698 g_browser_process->ReleaseModule(); |
699 } | 699 } |
700 | 700 |
701 virtual void Observe(int type, | 701 void Observe(int type, |
702 const content::NotificationSource& source, | 702 const content::NotificationSource& source, |
703 const content::NotificationDetails& details) override { | 703 const content::NotificationDetails& details) override { |
704 switch (type) { | 704 switch (type) { |
705 case chrome::NOTIFICATION_BROWSER_CLOSED: | 705 case chrome::NOTIFICATION_BROWSER_CLOSED: |
706 delete this; | 706 delete this; |
707 return; | 707 return; |
708 | 708 |
709 default: | 709 default: |
710 NOTREACHED(); | 710 NOTREACHED(); |
711 break; | 711 break; |
712 } | 712 } |
713 } | 713 } |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 if (!active_session_restorers) | 1291 if (!active_session_restorers) |
1292 return false; | 1292 return false; |
1293 for (std::set<SessionRestoreImpl*>::const_iterator it = | 1293 for (std::set<SessionRestoreImpl*>::const_iterator it = |
1294 active_session_restorers->begin(); | 1294 active_session_restorers->begin(); |
1295 it != active_session_restorers->end(); ++it) { | 1295 it != active_session_restorers->end(); ++it) { |
1296 if ((*it)->synchronous()) | 1296 if ((*it)->synchronous()) |
1297 return true; | 1297 return true; |
1298 } | 1298 } |
1299 return false; | 1299 return false; |
1300 } | 1300 } |
OLD | NEW |