Chromium Code Reviews| 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_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
| 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 PendingPrerenderData(Origin origin, | 74 PendingPrerenderData(Origin origin, |
| 75 const GURL& url, | 75 const GURL& url, |
| 76 const content::Referrer& referrer); | 76 const content::Referrer& referrer); |
| 77 | 77 |
| 78 Origin origin; | 78 Origin origin; |
| 79 GURL url; | 79 GURL url; |
| 80 content::Referrer referrer; | 80 content::Referrer referrer; |
| 81 }; | 81 }; |
| 82 typedef std::list<PendingPrerenderData> PendingPrerenderList; | 82 typedef std::list<PendingPrerenderData> PendingPrerenderList; |
| 83 | 83 |
| 84 // Indicates how this PrerenderContents relates to MatchComplete. | |
| 85 // This is important to figure out in what histograms to record the | |
| 86 // FinalStatus in, as described below. | |
| 87 enum MatchCompleteStatus { | |
| 88 // A regular prerender which will be recorded both in Match and | |
| 89 // MatchComplete. | |
| 90 MC_DEFAULT, | |
| 91 // A prerender that used to be a regular prerender, but has since | |
| 92 // been replaced by a MachComplete dummy. Therefore, we will record | |
|
dominich
2012/01/23 22:41:40
nit: MatchComplete
tburkard
2012/01/24 00:59:56
Done.
| |
| 93 // this only for Match, but not for MatchComplete. | |
| 94 MC_REPLACED, | |
| 95 // A prerender that is a MatchComplete dummy replacing a regular | |
| 96 // prerender. Therefore, we iwll record this only for MatchComplete, | |
|
dominich
2012/01/23 22:41:40
nit: will
tburkard
2012/01/24 00:59:56
Done.
| |
| 97 // but not Match. | |
| 98 MC_REPLACEMENT | |
| 99 }; | |
| 100 | |
| 84 virtual ~PrerenderContents(); | 101 virtual ~PrerenderContents(); |
| 85 | 102 |
| 86 bool Init(); | 103 bool Init(); |
| 87 | 104 |
| 88 static Factory* CreateFactory(); | 105 static Factory* CreateFactory(); |
| 89 | 106 |
| 90 // |source_render_view_host| is the RenderViewHost that initiated | 107 // |source_render_view_host| is the RenderViewHost that initiated |
| 91 // prerendering. | 108 // prerendering. |
| 92 virtual void StartPrerendering( | 109 virtual void StartPrerendering( |
| 93 const RenderViewHost* source_render_view_host, | 110 const RenderViewHost* source_render_view_host, |
| 94 SessionStorageNamespace* session_storage_namespace); | 111 SessionStorageNamespace* session_storage_namespace); |
| 95 | 112 |
| 96 // Verifies that the prerendering is not using too many resources, and kills | 113 // Verifies that the prerendering is not using too many resources, and kills |
| 97 // it if not. | 114 // it if not. |
| 98 void DestroyWhenUsingTooManyResources(); | 115 void DestroyWhenUsingTooManyResources(); |
| 99 | 116 |
| 100 RenderViewHost* render_view_host_mutable(); | 117 RenderViewHost* render_view_host_mutable(); |
| 101 const RenderViewHost* render_view_host() const; | 118 const RenderViewHost* render_view_host() const; |
| 102 string16 title() const { return title_; } | 119 string16 title() const { return title_; } |
| 103 int32 page_id() const { return page_id_; } | 120 int32 page_id() const { return page_id_; } |
| 104 GURL icon_url() const { return icon_url_; } | 121 GURL icon_url() const { return icon_url_; } |
| 105 const GURL& prerender_url() const { return prerender_url_; } | 122 const GURL& prerender_url() const { return prerender_url_; } |
| 106 const content::Referrer& referrer() const { return referrer_; } | 123 const content::Referrer& referrer() const { return referrer_; } |
| 107 bool has_stopped_loading() const { return has_stopped_loading_; } | 124 bool has_stopped_loading() const { return has_stopped_loading_; } |
| 108 bool prerendering_has_started() const { return prerendering_has_started_; } | 125 bool prerendering_has_started() const { return prerendering_has_started_; } |
| 126 MatchCompleteStatus mc_status() const { return mc_status_; } | |
|
dominich
2012/01/23 22:41:40
I understand this is used frequently, but it's Chr
tburkard
2012/01/24 00:59:56
Done.
| |
| 127 void set_mc_status(MatchCompleteStatus status) { mc_status_ = status; } | |
| 109 | 128 |
| 110 // Sets the parameter to the value of the associated RenderViewHost's child id | 129 // Sets the parameter to the value of the associated RenderViewHost's child id |
| 111 // and returns a boolean indicating the validity of that id. | 130 // and returns a boolean indicating the validity of that id. |
| 112 virtual bool GetChildId(int* child_id) const; | 131 virtual bool GetChildId(int* child_id) const; |
| 113 | 132 |
| 114 // Sets the parameter to the value of the associated RenderViewHost's route id | 133 // Sets the parameter to the value of the associated RenderViewHost's route id |
| 115 // and returns a boolean indicating the validity of that id. | 134 // and returns a boolean indicating the validity of that id. |
| 116 virtual bool GetRouteId(int* route_id) const; | 135 virtual bool GetRouteId(int* route_id) const; |
| 117 | 136 |
| 118 // Set the final status for how the PrerenderContents was used. This | 137 // Set the final status for how the PrerenderContents was used. This |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 std::vector<GURL> alias_urls_; | 281 std::vector<GURL> alias_urls_; |
| 263 | 282 |
| 264 bool has_stopped_loading_; | 283 bool has_stopped_loading_; |
| 265 | 284 |
| 266 // This must be the same value as the PrerenderTracker has recorded for | 285 // This must be the same value as the PrerenderTracker has recorded for |
| 267 // |this|, when |this| has a RenderView. | 286 // |this|, when |this| has a RenderView. |
| 268 FinalStatus final_status_; | 287 FinalStatus final_status_; |
| 269 | 288 |
| 270 bool prerendering_has_started_; | 289 bool prerendering_has_started_; |
| 271 | 290 |
| 291 // The MatchComplete status of the prerender, indicating how it relates | |
| 292 // to being a MatchComplete dummy (see definition of MatchCompleteStatus | |
| 293 // above). | |
| 294 MatchCompleteStatus mc_status_; | |
| 295 | |
| 272 // Tracks whether or not prerendering has been cancelled by calling Destroy. | 296 // Tracks whether or not prerendering has been cancelled by calling Destroy. |
| 273 // Used solely to prevent double deletion. | 297 // Used solely to prevent double deletion. |
| 274 bool prerendering_has_been_cancelled_; | 298 bool prerendering_has_been_cancelled_; |
| 275 | 299 |
| 276 // Time at which we started to load the URL. This is used to compute | 300 // Time at which we started to load the URL. This is used to compute |
| 277 // the time elapsed from initiating a prerender until the time the | 301 // the time elapsed from initiating a prerender until the time the |
| 278 // (potentially only partially) prerendered page is shown to the user. | 302 // (potentially only partially) prerendered page is shown to the user. |
| 279 base::TimeTicks load_start_time_; | 303 base::TimeTicks load_start_time_; |
| 280 | 304 |
| 281 // Process Metrics of the render process associated with the | 305 // Process Metrics of the render process associated with the |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 301 | 325 |
| 302 // List of all pages the prerendered page has tried to prerender. | 326 // List of all pages the prerendered page has tried to prerender. |
| 303 PendingPrerenderList pending_prerender_list_; | 327 PendingPrerenderList pending_prerender_list_; |
| 304 | 328 |
| 305 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 329 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
| 306 }; | 330 }; |
| 307 | 331 |
| 308 } // namespace prerender | 332 } // namespace prerender |
| 309 | 333 |
| 310 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 334 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
| OLD | NEW |