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

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

Issue 9147026: API for connection type (Ethernet/WIFI/WWAN ...) in NetworkChangeNotifier. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 11 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
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>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 // TabLoader is responsible for loading tabs after session restore creates 58 // TabLoader is responsible for loading tabs after session restore creates
59 // tabs. New tabs are loaded after the current tab finishes loading, or a delay 59 // tabs. New tabs are loaded after the current tab finishes loading, or a delay
60 // is reached (initially kInitialDelayTimerMS). If the delay is reached before 60 // is reached (initially kInitialDelayTimerMS). If the delay is reached before
61 // a tab finishes loading a new tab is loaded and the time of the delay 61 // a tab finishes loading a new tab is loaded and the time of the delay
62 // doubled. When all tabs are loading TabLoader deletes itself. 62 // doubled. When all tabs are loading TabLoader deletes itself.
63 // 63 //
64 // This is not part of SessionRestoreImpl so that synchronous destruction 64 // This is not part of SessionRestoreImpl so that synchronous destruction
65 // of SessionRestoreImpl doesn't have timing problems. 65 // of SessionRestoreImpl doesn't have timing problems.
66 class TabLoader : public content::NotificationObserver, 66 class TabLoader : public content::NotificationObserver,
67 public net::NetworkChangeNotifier::OnlineStateObserver { 67 public net::NetworkChangeNotifier::ConnectionStateObserver {
68 public: 68 public:
69 explicit TabLoader(base::TimeTicks restore_started); 69 explicit TabLoader(base::TimeTicks restore_started);
70 virtual ~TabLoader(); 70 virtual ~TabLoader();
71 71
72 // Schedules a tab for loading. 72 // Schedules a tab for loading.
73 void ScheduleLoad(NavigationController* controller); 73 void ScheduleLoad(NavigationController* controller);
74 74
75 // Notifies the loader that a tab has been scheduled for loading through 75 // Notifies the loader that a tab has been scheduled for loading through
76 // some other mechanism. 76 // some other mechanism.
77 void TabIsLoading(NavigationController* controller); 77 void TabIsLoading(NavigationController* controller);
(...skipping 12 matching lines...) Expand all
90 // otherwise |force_load_timer_| is restarted. 90 // otherwise |force_load_timer_| is restarted.
91 void LoadNextTab(); 91 void LoadNextTab();
92 92
93 // NotificationObserver method. Removes the specified tab and loads the next 93 // NotificationObserver method. Removes the specified tab and loads the next
94 // tab. 94 // tab.
95 virtual void Observe(int type, 95 virtual void Observe(int type,
96 const content::NotificationSource& source, 96 const content::NotificationSource& source,
97 const content::NotificationDetails& details) OVERRIDE; 97 const content::NotificationDetails& details) OVERRIDE;
98 98
99 // net::NetworkChangeNotifier::OnlineStateObserver overrides. 99 // net::NetworkChangeNotifier::OnlineStateObserver overrides.
100 virtual void OnOnlineStateChanged(bool online) OVERRIDE; 100 virtual void OnConnectionStateChanged(
101 net::NetworkChangeNotifier::ConnectionState state) OVERRIDE;
101 102
102 // Removes the listeners from the specified tab and removes the tab from 103 // Removes the listeners from the specified tab and removes the tab from
103 // the set of tabs to load and list of tabs we're waiting to get a load 104 // the set of tabs to load and list of tabs we're waiting to get a load
104 // from. 105 // from.
105 void RemoveTab(NavigationController* tab); 106 void RemoveTab(NavigationController* tab);
106 107
107 // Invoked from |force_load_timer_|. Doubles |force_load_delay_| and invokes 108 // Invoked from |force_load_timer_|. Doubles |force_load_delay_| and invokes
108 // |LoadNextTab| to load the next tab 109 // |LoadNextTab| to load the next tab
109 void ForceLoadTimerFired(); 110 void ForceLoadTimerFired();
110 111
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 : force_load_delay_(kInitialDelayTimerMS), 159 : force_load_delay_(kInitialDelayTimerMS),
159 loading_(false), 160 loading_(false),
160 got_first_paint_(false), 161 got_first_paint_(false),
161 tab_count_(0), 162 tab_count_(0),
162 restore_started_(restore_started) { 163 restore_started_(restore_started) {
163 } 164 }
164 165
165 TabLoader::~TabLoader() { 166 TabLoader::~TabLoader() {
166 DCHECK((got_first_paint_ || render_widget_hosts_to_paint_.empty()) && 167 DCHECK((got_first_paint_ || render_widget_hosts_to_paint_.empty()) &&
167 tabs_loading_.empty() && tabs_to_load_.empty()); 168 tabs_loading_.empty() && tabs_to_load_.empty());
168 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); 169 net::NetworkChangeNotifier::RemoveConnectionStateObserver(this);
169 } 170 }
170 171
171 void TabLoader::ScheduleLoad(NavigationController* controller) { 172 void TabLoader::ScheduleLoad(NavigationController* controller) {
172 DCHECK(controller); 173 DCHECK(controller);
173 DCHECK(find(tabs_to_load_.begin(), tabs_to_load_.end(), controller) == 174 DCHECK(find(tabs_to_load_.begin(), tabs_to_load_.end(), controller) ==
174 tabs_to_load_.end()); 175 tabs_to_load_.end());
175 tabs_to_load_.push_back(controller); 176 tabs_to_load_.push_back(controller);
176 RegisterForNotifications(controller); 177 RegisterForNotifications(controller);
177 } 178 }
178 179
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 311 }
311 default: 312 default:
312 NOTREACHED() << "Unknown notification received:" << type; 313 NOTREACHED() << "Unknown notification received:" << type;
313 } 314 }
314 // Delete ourselves when we're not waiting for any more notifications. 315 // Delete ourselves when we're not waiting for any more notifications.
315 if ((got_first_paint_ || render_widget_hosts_to_paint_.empty()) && 316 if ((got_first_paint_ || render_widget_hosts_to_paint_.empty()) &&
316 tabs_loading_.empty() && tabs_to_load_.empty()) 317 tabs_loading_.empty() && tabs_to_load_.empty())
317 delete this; 318 delete this;
318 } 319 }
319 320
320 void TabLoader::OnOnlineStateChanged(bool online) { 321 void TabLoader::OnConnectionStateChanged(
321 if (online) { 322 net::NetworkChangeNotifier::ConnectionState state) {
323 if (state != net::NetworkChangeNotifier::NONE) {
joth 2012/01/10 10:48:35 nit: wrong indent
322 if (!loading_) { 324 if (!loading_) {
323 loading_ = true; 325 loading_ = true;
324 LoadNextTab(); 326 LoadNextTab();
325 } 327 }
326 } else { 328 } else {
327 loading_ = false; 329 loading_ = false;
328 } 330 }
329 } 331 }
330 332
331 void TabLoader::RemoveTab(NavigationController* tab) { 333 void TabLoader::RemoveTab(NavigationController* tab) {
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 std::vector<GURL> gurls; 902 std::vector<GURL> gurls;
901 SessionRestoreImpl restorer(profile, 903 SessionRestoreImpl restorer(profile,
902 static_cast<Browser*>(NULL), true, false, true, gurls); 904 static_cast<Browser*>(NULL), true, false, true, gurls);
903 restorer.RestoreForeignTab(tab); 905 restorer.RestoreForeignTab(tab);
904 } 906 }
905 907
906 // static 908 // static
907 bool SessionRestore::IsRestoring() { 909 bool SessionRestore::IsRestoring() {
908 return restoring; 910 return restoring;
909 } 911 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698