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

Side by Side Diff: chrome/browser/prerender/prerender_manager.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
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/prerender/prerender_manager.h" 5 #include "chrome/browser/prerender/prerender_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 class PrerenderManager::OnCloseWebContentsDeleter 149 class PrerenderManager::OnCloseWebContentsDeleter
150 : public content::WebContentsDelegate, 150 : public content::WebContentsDelegate,
151 public base::SupportsWeakPtr< 151 public base::SupportsWeakPtr<
152 PrerenderManager::OnCloseWebContentsDeleter> { 152 PrerenderManager::OnCloseWebContentsDeleter> {
153 public: 153 public:
154 OnCloseWebContentsDeleter(PrerenderManager* manager, 154 OnCloseWebContentsDeleter(PrerenderManager* manager,
155 WebContents* tab) 155 WebContents* tab)
156 : manager_(manager), 156 : manager_(manager),
157 tab_(tab) { 157 tab_(tab) {
158 tab_->SetDelegate(this); 158 tab_->SetDelegate(this);
159 MessageLoop::current()->PostDelayedTask(FROM_HERE, 159 base::MessageLoop::current()->PostDelayedTask(FROM_HERE,
160 base::Bind(&OnCloseWebContentsDeleter::ScheduleWebContentsForDeletion, 160 base::Bind(&OnCloseWebContentsDeleter::ScheduleWebContentsForDeletion,
161 AsWeakPtr(), true), 161 AsWeakPtr(), true),
162 base::TimeDelta::FromSeconds(kDeleteWithExtremePrejudiceSeconds)); 162 base::TimeDelta::FromSeconds(kDeleteWithExtremePrejudiceSeconds));
163 } 163 }
164 164
165 virtual void CloseContents(WebContents* source) OVERRIDE { 165 virtual void CloseContents(WebContents* source) OVERRIDE {
166 DCHECK_EQ(tab_, source); 166 DCHECK_EQ(tab_, source);
167 ScheduleWebContentsForDeletion(false); 167 ScheduleWebContentsForDeletion(false);
168 } 168 }
169 169
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 // And now check for prerenders using too much memory. 1180 // And now check for prerenders using too much memory.
1181 std::for_each(prerender_contents.begin(), prerender_contents.end(), 1181 std::for_each(prerender_contents.begin(), prerender_contents.end(),
1182 std::mem_fun( 1182 std::mem_fun(
1183 &PrerenderContents::DestroyWhenUsingTooManyResources)); 1183 &PrerenderContents::DestroyWhenUsingTooManyResources));
1184 1184
1185 to_delete_prerenders_.clear(); 1185 to_delete_prerenders_.clear();
1186 } 1186 }
1187 1187
1188 void PrerenderManager::PostCleanupTask() { 1188 void PrerenderManager::PostCleanupTask() {
1189 DCHECK(CalledOnValidThread()); 1189 DCHECK(CalledOnValidThread());
1190 MessageLoop::current()->PostTask( 1190 base::MessageLoop::current()->PostTask(
1191 FROM_HERE, 1191 FROM_HERE,
1192 base::Bind(&PrerenderManager::PeriodicCleanup, AsWeakPtr())); 1192 base::Bind(&PrerenderManager::PeriodicCleanup, AsWeakPtr()));
1193 } 1193 }
1194 1194
1195 base::TimeTicks PrerenderManager::GetExpiryTimeForNewPrerender( 1195 base::TimeTicks PrerenderManager::GetExpiryTimeForNewPrerender(
1196 Origin origin) const { 1196 Origin origin) const {
1197 base::TimeDelta ttl = config_.time_to_live; 1197 base::TimeDelta ttl = config_.time_to_live;
1198 if (origin == ORIGIN_LOCAL_PREDICTOR) 1198 if (origin == ORIGIN_LOCAL_PREDICTOR)
1199 ttl = base::TimeDelta::FromSeconds(180); 1199 ttl = base::TimeDelta::FromSeconds(180);
1200 return GetCurrentTimeTicks() + ttl; 1200 return GetCurrentTimeTicks() + ttl;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 logged_in_state_->erase(domain_key); 1519 logged_in_state_->erase(domain_key);
1520 } 1520 }
1521 1521
1522 void PrerenderManager::LoggedInPredictorDataReceived( 1522 void PrerenderManager::LoggedInPredictorDataReceived(
1523 scoped_ptr<LoggedInStateMap> new_map) { 1523 scoped_ptr<LoggedInStateMap> new_map) {
1524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1525 logged_in_state_.swap(new_map); 1525 logged_in_state_.swap(new_map);
1526 } 1526 }
1527 1527
1528 } // namespace prerender 1528 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_local_predictor.cc ('k') | chrome/browser/prerender/prerender_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698