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 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 static bool IsValidHttpMethod(const std::string& method); | 189 static bool IsValidHttpMethod(const std::string& method); |
190 | 190 |
191 // Returns a Value object containing the active pages being prerendered, and | 191 // Returns a Value object containing the active pages being prerendered, and |
192 // a history of pages which were prerendered. The caller is responsible for | 192 // a history of pages which were prerendered. The caller is responsible for |
193 // deleting the return value. | 193 // deleting the return value. |
194 base::DictionaryValue* GetAsValue() const; | 194 base::DictionaryValue* GetAsValue() const; |
195 | 195 |
196 // Clears the data indicated by which bits of clear_flags are set. | 196 // Clears the data indicated by which bits of clear_flags are set. |
197 // | 197 // |
198 // If the CLEAR_PRERENDER_CONTENTS bit is set, all active prerenders are | 198 // If the CLEAR_PRERENDER_CONTENTS bit is set, all active prerenders are |
199 // cancelled and then deleted, and any TabContents queued for destruction are | 199 // cancelled and then deleted, and any WebContents queued for destruction are |
200 // destroyed as well. | 200 // destroyed as well. |
201 // | 201 // |
202 // If the CLEAR_PRERENDER_HISTORY bit is set, the prerender history is | 202 // If the CLEAR_PRERENDER_HISTORY bit is set, the prerender history is |
203 // cleared, including any entries newly created by destroying them in | 203 // cleared, including any entries newly created by destroying them in |
204 // response to the CLEAR_PRERENDER_CONTENTS flag. | 204 // response to the CLEAR_PRERENDER_CONTENTS flag. |
205 // | 205 // |
206 // Intended to be used when clearing the cache or history. | 206 // Intended to be used when clearing the cache or history. |
207 void ClearData(int clear_flags); | 207 void ClearData(int clear_flags); |
208 | 208 |
209 // Record a final status of a prerendered page in a histogram. | 209 // Record a final status of a prerendered page in a histogram. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 // to doing the prerendered itself, will return NULL. | 303 // to doing the prerendered itself, will return NULL. |
304 PrerenderContents* GetEntryButNotSpecifiedWC(const GURL& url, | 304 PrerenderContents* GetEntryButNotSpecifiedWC(const GURL& url, |
305 content::WebContents* wc); | 305 content::WebContents* wc); |
306 | 306 |
307 // Starts scheduling periodic cleanups. | 307 // Starts scheduling periodic cleanups. |
308 void StartSchedulingPeriodicCleanups(); | 308 void StartSchedulingPeriodicCleanups(); |
309 // Stops scheduling periodic cleanups if they're no longer needed. | 309 // Stops scheduling periodic cleanups if they're no longer needed. |
310 void MaybeStopSchedulingPeriodicCleanups(); | 310 void MaybeStopSchedulingPeriodicCleanups(); |
311 | 311 |
312 // Deletes stale and cancelled prerendered PrerenderContents, as well as | 312 // Deletes stale and cancelled prerendered PrerenderContents, as well as |
313 // TabContents that have been replaced by prerendered TabContents. | 313 // WebContents that have been replaced by prerendered WebContents. |
314 // Also identifies and kills PrerenderContents that use too much | 314 // Also identifies and kills PrerenderContents that use too much |
315 // resources. | 315 // resources. |
316 void PeriodicCleanup(); | 316 void PeriodicCleanup(); |
317 | 317 |
318 // Posts a task to call PeriodicCleanup. Results in quicker destruction of | 318 // Posts a task to call PeriodicCleanup. Results in quicker destruction of |
319 // objects. If |this| is deleted before the task is run, the task will | 319 // objects. If |this| is deleted before the task is run, the task will |
320 // automatically be cancelled. | 320 // automatically be cancelled. |
321 void PostCleanupTask(); | 321 void PostCleanupTask(); |
322 | 322 |
323 base::TimeDelta GetMaxAge() const; | 323 base::TimeDelta GetMaxAge() const; |
(...skipping 20 matching lines...) Expand all Loading... |
344 PrerenderContents* FindEntry(const GURL& url) const; | 344 PrerenderContents* FindEntry(const GURL& url) const; |
345 | 345 |
346 // Returns the iterator to the PrerenderContentsData entry that is being | 346 // Returns the iterator to the PrerenderContentsData entry that is being |
347 // prerendered from the given child route id pair. | 347 // prerendered from the given child route id pair. |
348 PrerenderContentsDataList::iterator | 348 PrerenderContentsDataList::iterator |
349 FindPrerenderContentsForChildRouteIdPair( | 349 FindPrerenderContentsForChildRouteIdPair( |
350 const std::pair<int, int>& child_route_id_pair); | 350 const std::pair<int, int>& child_route_id_pair); |
351 | 351 |
352 bool DoesRateLimitAllowPrerender() const; | 352 bool DoesRateLimitAllowPrerender() const; |
353 | 353 |
354 // Deletes old TabContents that have been replaced by prerendered ones. This | 354 // Deletes old WebContents that have been replaced by prerendered ones. This |
355 // is needed because they're replaced in a callback from the old TabContents, | 355 // is needed because they're replaced in a callback from the old WebContents, |
356 // so cannot immediately be deleted. | 356 // so cannot immediately be deleted. |
357 void DeleteOldTabContents(); | 357 void DeleteOldTabContents(); |
358 | 358 |
359 // Cleans up old NavigationRecord's. | 359 // Cleans up old NavigationRecord's. |
360 void CleanUpOldNavigations(); | 360 void CleanUpOldNavigations(); |
361 | 361 |
362 // Arrange for the given tab contents to be deleted asap. If deleter is not | 362 // Arrange for the given tab contents to be deleted asap. If deleter is not |
363 // NULL, deletes that as well. | 363 // NULL, deletes that as well. |
364 void ScheduleDeleteOldTabContents(TabContentsWrapper* tab, | 364 void ScheduleDeleteOldTabContents(TabContentsWrapper* tab, |
365 OnCloseTabContentsDeleter* deleter); | 365 OnCloseTabContentsDeleter* deleter); |
366 | 366 |
367 // Adds to the history list. | 367 // Adds to the history list. |
368 void AddToHistory(PrerenderContents* contents); | 368 void AddToHistory(PrerenderContents* contents); |
369 | 369 |
370 // Returns a new Value representing the pages currently being prerendered. The | 370 // Returns a new Value representing the pages currently being prerendered. The |
371 // caller is responsible for delete'ing the return value. | 371 // caller is responsible for delete'ing the return value. |
372 base::Value* GetActivePrerendersAsValue() const; | 372 base::Value* GetActivePrerendersAsValue() const; |
373 | 373 |
374 // Destroys all pending prerenders using FinalStatus. Also deletes them as | 374 // Destroys all pending prerenders using FinalStatus. Also deletes them as |
375 // well as any swapped out TabContents queued for destruction. | 375 // well as any swapped out WebContents queued for destruction. |
376 // Used both on destruction, and when clearing the browsing history. | 376 // Used both on destruction, and when clearing the browsing history. |
377 void DestroyAllContents(FinalStatus final_status); | 377 void DestroyAllContents(FinalStatus final_status); |
378 | 378 |
379 // Helper function to destroy a PrerenderContents with the specified | 379 // Helper function to destroy a PrerenderContents with the specified |
380 // final_status, while at the same time recording that for the MatchComplete | 380 // final_status, while at the same time recording that for the MatchComplete |
381 // case, that this prerender would have been used. | 381 // case, that this prerender would have been used. |
382 void DestroyAndMarkMatchCompleteAsUsed(PrerenderContents* prerender_contents, | 382 void DestroyAndMarkMatchCompleteAsUsed(PrerenderContents* prerender_contents, |
383 FinalStatus final_status); | 383 FinalStatus final_status); |
384 | 384 |
385 // Record a final status of a prerendered page in a histogram. | 385 // Record a final status of a prerendered page in a histogram. |
(...skipping 25 matching lines...) Expand all Loading... |
411 // List of prerendered elements. | 411 // List of prerendered elements. |
412 PrerenderContentsDataList prerender_list_; | 412 PrerenderContentsDataList prerender_list_; |
413 | 413 |
414 // List of recent navigations in this profile, sorted by ascending | 414 // List of recent navigations in this profile, sorted by ascending |
415 // navigate_time_. | 415 // navigate_time_. |
416 std::list<NavigationRecord> navigations_; | 416 std::list<NavigationRecord> navigations_; |
417 | 417 |
418 // List of prerender elements to be deleted | 418 // List of prerender elements to be deleted |
419 std::list<PrerenderContents*> pending_delete_list_; | 419 std::list<PrerenderContents*> pending_delete_list_; |
420 | 420 |
421 // Set of TabContents which are currently displaying a prerendered page. | 421 // Set of WebContents which are currently displaying a prerendered page. |
422 base::hash_set<content::WebContents*> prerendered_tab_contents_set_; | 422 base::hash_set<content::WebContents*> prerendered_tab_contents_set_; |
423 | 423 |
424 // Set of TabContents which would be displaying a prerendered page | 424 // Set of WebContents which would be displaying a prerendered page |
425 // (for the control group). | 425 // (for the control group). |
426 base::hash_set<content::WebContents*> would_be_prerendered_tab_contents_set_; | 426 base::hash_set<content::WebContents*> would_be_prerendered_tab_contents_set_; |
427 | 427 |
428 scoped_ptr<PrerenderContents::Factory> prerender_contents_factory_; | 428 scoped_ptr<PrerenderContents::Factory> prerender_contents_factory_; |
429 | 429 |
430 static PrerenderManagerMode mode_; | 430 static PrerenderManagerMode mode_; |
431 | 431 |
432 // A count of how many prerenders we do per session. Initialized to 0 then | 432 // A count of how many prerenders we do per session. Initialized to 0 then |
433 // incremented and emitted to a histogram on each successful prerender. | 433 // incremented and emitted to a histogram on each successful prerender. |
434 static int prerenders_per_session_count_; | 434 static int prerenders_per_session_count_; |
(...skipping 22 matching lines...) Expand all Loading... |
457 | 457 |
458 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 458 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
459 }; | 459 }; |
460 | 460 |
461 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 461 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
462 int render_process_id); | 462 int render_process_id); |
463 | 463 |
464 } // namespace prerender | 464 } // namespace prerender |
465 | 465 |
466 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 466 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |