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

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

Issue 11316311: Make PrerenderHandle an observer of PrerenderContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase trunk & add upstream remediation Created 8 years 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 #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 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // provided URL. 261 // provided URL.
262 void RecordNavigation(const GURL& url); 262 void RecordNavigation(const GURL& url);
263 263
264 Profile* profile() const { return profile_; } 264 Profile* profile() const { return profile_; }
265 265
266 protected: 266 protected:
267 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> { 267 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> {
268 public: 268 public:
269 struct OrderByExpiryTime; 269 struct OrderByExpiryTime;
270 270
271 // Constructor for a pending prerender, which will get its contents later.
272 explicit PrerenderData(PrerenderManager* manager);
273
274 // Constructor for an active prerender.
275 PrerenderData(PrerenderManager* manager, 271 PrerenderData(PrerenderManager* manager,
276 PrerenderContents* contents, 272 PrerenderContents* contents,
277 base::TimeTicks expiry_time); 273 base::TimeTicks expiry_time);
278 274
279 ~PrerenderData(); 275 ~PrerenderData();
280 276
281 // Turn this PrerenderData into a Match Complete replacement for itself, 277 // Turn this PrerenderData into a Match Complete replacement for itself,
282 // placing the current prerender contents into |to_delete_prerenders_|. 278 // placing the current prerender contents into |to_delete_prerenders_|.
283 void MakeIntoMatchCompleteReplacement(); 279 void MakeIntoMatchCompleteReplacement();
284 280
285 // A new PrerenderHandle has been created for this PrerenderData. 281 // A new PrerenderHandle has been created for this PrerenderData.
286 void OnNewHandle(); 282 void OnNewHandle(PrerenderHandle* prerender_handle);
287 283
288 // The launcher associated with a handle is navigating away from the context 284 // The launcher associated with a handle is navigating away from the context
289 // that launched this prerender. If the prerender is active, it may stay 285 // that launched this prerender. If the prerender is active, it may stay
290 // alive briefly though, in case we we going through a redirect chain that 286 // alive briefly though, in case we we going through a redirect chain that
291 // will eventually land at it. 287 // will eventually land at it.
292 void OnNavigateAwayByHandle(); 288 void OnNavigateAwayByHandle(PrerenderHandle* prerender_handle);
293 289
294 // The launcher associated with a handle has taken explicit action to cancel 290 // The launcher associated with a handle has taken explicit action to cancel
295 // this prerender. We may well destroy the prerender in this case if no 291 // this prerender. We may well destroy the prerender in this case if no
296 // other handles continue to track it. 292 // other handles continue to track it.
297 void OnCancelByHandle(); 293 void OnCancelByHandle(PrerenderHandle* prerender_handle);
298 294
299 PrerenderContents* contents() { return contents_.get(); } 295 PrerenderContents* contents() { return contents_.get(); }
300 296
301 PrerenderContents* ReleaseContents(); 297 PrerenderContents* ReleaseContents();
302 298
303 int handle_count() const { return handle_count_; } 299 int handle_count() const { return handle_count_; }
304 300
305 base::TimeTicks expiry_time() const { return expiry_time_; } 301 base::TimeTicks expiry_time() const { return expiry_time_; }
306 void set_expiry_time(base::TimeTicks expiry_time) { 302 void set_expiry_time(base::TimeTicks expiry_time) {
307 expiry_time_ = expiry_time; 303 expiry_time_ = expiry_time;
(...skipping 20 matching lines...) Expand all
328 void SetPrerenderContentsFactory( 324 void SetPrerenderContentsFactory(
329 PrerenderContents::Factory* prerender_contents_factory); 325 PrerenderContents::Factory* prerender_contents_factory);
330 326
331 // Adds prerenders from the pending Prerenders, called by 327 // Adds prerenders from the pending Prerenders, called by
332 // PrerenderContents::StartPendingPrerenders. 328 // PrerenderContents::StartPendingPrerenders.
333 void StartPendingPrerenders( 329 void StartPendingPrerenders(
334 int process_id, 330 int process_id,
335 ScopedVector<PrerenderContents::PendingPrerenderInfo>* pending_prerenders, 331 ScopedVector<PrerenderContents::PendingPrerenderInfo>* pending_prerenders,
336 content::SessionStorageNamespace* session_storage_namespace); 332 content::SessionStorageNamespace* session_storage_namespace);
337 333
338 // Called by a PrerenderData to self-destroy, but only when the PrerenderData
339 // is pending (as in not yet active). Should not be called except for
340 // objects known to be in |pending_prerender_list_|.
341 void DestroyPendingPrerenderData(PrerenderData* pending_prerender_data);
342
343 // Called by a PrerenderData to signal that the launcher has navigated away 334 // Called by a PrerenderData to signal that the launcher has navigated away
344 // from the context that launched the prerender. A user may have clicked 335 // from the context that launched the prerender. A user may have clicked
345 // a link in a page containing a <link rel=prerender> element, or the user 336 // a link in a page containing a <link rel=prerender> element, or the user
346 // might have committed an omnibox navigation. This is used to possibly 337 // might have committed an omnibox navigation. This is used to possibly
347 // shorten the TTL of the prerendered page. 338 // shorten the TTL of the prerendered page.
348 void SourceNavigatedAway(PrerenderData* prerender_data); 339 void SourceNavigatedAway(PrerenderData* prerender_data);
349 340
350 private: 341 private:
351 friend class PrerenderBrowserTest; 342 friend class PrerenderBrowserTest;
352 friend class PrerenderContents; 343 friend class PrerenderContents;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 static bool is_prefetch_enabled_; 503 static bool is_prefetch_enabled_;
513 504
514 // The profile that owns this PrerenderManager. 505 // The profile that owns this PrerenderManager.
515 Profile* profile_; 506 Profile* profile_;
516 507
517 PrerenderTracker* prerender_tracker_; 508 PrerenderTracker* prerender_tracker_;
518 509
519 // All running prerenders. Sorted by expiry time, in ascending order. 510 // All running prerenders. Sorted by expiry time, in ascending order.
520 ScopedVector<PrerenderData> active_prerenders_; 511 ScopedVector<PrerenderData> active_prerenders_;
521 512
522 // All pending prerenders.
523 ScopedVector<PrerenderData> pending_prerenders_;
524
525 // Prerenders awaiting deletion. 513 // Prerenders awaiting deletion.
526 ScopedVector<PrerenderData> to_delete_prerenders_; 514 ScopedVector<PrerenderData> to_delete_prerenders_;
527 515
528 // List of recent navigations in this profile, sorted by ascending 516 // List of recent navigations in this profile, sorted by ascending
529 // navigate_time_. 517 // navigate_time_.
530 std::list<NavigationRecord> navigations_; 518 std::list<NavigationRecord> navigations_;
531 519
532 // This map is from all WebContents which are currently displaying a 520 // This map is from all WebContents which are currently displaying a
533 // prerendered page which has already been swapped in to a 521 // prerendered page which has already been swapped in to a
534 // PrerenderedWebContentsData for tracking full lifetime information 522 // PrerenderedWebContentsData for tracking full lifetime information
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 568
581 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); 569 DISALLOW_COPY_AND_ASSIGN(PrerenderManager);
582 }; 570 };
583 571
584 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( 572 PrerenderManager* FindPrerenderManagerUsingRenderProcessId(
585 int render_process_id); 573 int render_process_id);
586 574
587 } // namespace prerender 575 } // namespace prerender
588 576
589 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ 577 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698