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

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

Issue 1977463002: Prerender: Remove MatchComplete status. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 4 years, 7 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) 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 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // Signals that the prerender has stopped running. A PrerenderContents with 84 // Signals that the prerender has stopped running. A PrerenderContents with
85 // an unset final status will always call OnPrerenderStop before being 85 // an unset final status will always call OnPrerenderStop before being
86 // destroyed. 86 // destroyed.
87 virtual void OnPrerenderStop(PrerenderContents* contents) = 0; 87 virtual void OnPrerenderStop(PrerenderContents* contents) = 0;
88 88
89 protected: 89 protected:
90 Observer(); 90 Observer();
91 virtual ~Observer() = 0; 91 virtual ~Observer() = 0;
92 }; 92 };
93 93
94 // Indicates how this PrerenderContents relates to MatchComplete. This is to
95 // figure out which histograms to use to record the FinalStatus, Match (record
96 // all prerenders and control group prerenders) or MatchComplete (record
97 // running prerenders only in the way they would have been recorded in the
98 // control group).
99 // TODO(pasko): Remove the dead code associated with non-default
100 // MatchCompleteStatus.
101 enum MatchCompleteStatus {
102 // A regular prerender which will be recorded both in Match and
103 // MatchComplete.
104 MATCH_COMPLETE_DEFAULT,
105 // A prerender that used to be a regular prerender, but has since been
106 // replaced by a MatchComplete dummy. Therefore, we will record this only
107 // for Match, but not for MatchComplete.
108 MATCH_COMPLETE_REPLACED,
109 // A prerender that is a MatchComplete dummy replacing a regular prerender.
110 // In the control group, our prerender never would have been canceled, so
111 // we record in MatchComplete but not Match.
112 MATCH_COMPLETE_REPLACEMENT,
113 // A prerender that is a MatchComplete dummy, early in the process of being
114 // created. This prerender should not fail. Record for MatchComplete, but
115 // not Match.
116 MATCH_COMPLETE_REPLACEMENT_PENDING,
117 };
118
119 ~PrerenderContents() override; 94 ~PrerenderContents() override;
120 95
121 // All observers of a PrerenderContents are removed after the OnPrerenderStop 96 // All observers of a PrerenderContents are removed after the OnPrerenderStop
122 // event is sent, so there is no need to call RemoveObserver() in the normal 97 // event is sent, so there is no need to call RemoveObserver() in the normal
123 // use case. 98 // use case.
124 void AddObserver(Observer* observer); 99 void AddObserver(Observer* observer);
125 void RemoveObserver(Observer* observer); 100 void RemoveObserver(Observer* observer);
126 101
127 // For MatchComplete correctness, create a dummy replacement prerender
128 // contents to stand in for this prerender contents that (which we are about
129 // to destroy).
130 PrerenderContents* CreateMatchCompleteReplacement();
131
132 bool Init(); 102 bool Init();
133 103
134 static Factory* CreateFactory(); 104 static Factory* CreateFactory();
135 105
136 // Returns a PrerenderContents from the given web_contents, if it's used for 106 // Returns a PrerenderContents from the given web_contents, if it's used for
137 // prerendering. Otherwise returns NULL. Handles a NULL input for 107 // prerendering. Otherwise returns NULL. Handles a NULL input for
138 // convenience. 108 // convenience.
139 static PrerenderContents* FromWebContents(content::WebContents* web_contents); 109 static PrerenderContents* FromWebContents(content::WebContents* web_contents);
140 110
141 // Start rendering the contents in the prerendered state. If 111 // Start rendering the contents in the prerendered state. If
(...skipping 14 matching lines...) Expand all
156 const content::RenderViewHost* GetRenderViewHost() const; 126 const content::RenderViewHost* GetRenderViewHost() const;
157 127
158 PrerenderManager* prerender_manager() { return prerender_manager_; } 128 PrerenderManager* prerender_manager() { return prerender_manager_; }
159 129
160 base::string16 title() const { return title_; } 130 base::string16 title() const { return title_; }
161 const GURL& prerender_url() const { return prerender_url_; } 131 const GURL& prerender_url() const { return prerender_url_; }
162 const content::Referrer& referrer() const { return referrer_; } 132 const content::Referrer& referrer() const { return referrer_; }
163 bool has_stopped_loading() const { return has_stopped_loading_; } 133 bool has_stopped_loading() const { return has_stopped_loading_; }
164 bool has_finished_loading() const { return has_finished_loading_; } 134 bool has_finished_loading() const { return has_finished_loading_; }
165 bool prerendering_has_started() const { return prerendering_has_started_; } 135 bool prerendering_has_started() const { return prerendering_has_started_; }
166 MatchCompleteStatus match_complete_status() const {
167 return match_complete_status_;
168 }
169 void set_match_complete_status(MatchCompleteStatus status) {
170 match_complete_status_ = status;
171 }
172 136
173 // Sets the parameter to the value of the associated RenderViewHost's child id 137 // Sets the parameter to the value of the associated RenderViewHost's child id
174 // and returns a boolean indicating the validity of that id. 138 // and returns a boolean indicating the validity of that id.
175 virtual bool GetChildId(int* child_id) const; 139 virtual bool GetChildId(int* child_id) const;
176 140
177 // Sets the parameter to the value of the associated RenderViewHost's route id 141 // Sets the parameter to the value of the associated RenderViewHost's route id
178 // and returns a boolean indicating the validity of that id. 142 // and returns a boolean indicating the validity of that id.
179 virtual bool GetRouteId(int* route_id) const; 143 virtual bool GetRouteId(int* route_id) const;
180 144
181 FinalStatus final_status() const { return final_status_; } 145 FinalStatus final_status() const { return final_status_; }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // such as HTTP redirects or javascript redirects. 319 // such as HTTP redirects or javascript redirects.
356 std::vector<GURL> alias_urls_; 320 std::vector<GURL> alias_urls_;
357 321
358 bool has_stopped_loading_; 322 bool has_stopped_loading_;
359 323
360 // True when the main frame has finished loading. 324 // True when the main frame has finished loading.
361 bool has_finished_loading_; 325 bool has_finished_loading_;
362 326
363 FinalStatus final_status_; 327 FinalStatus final_status_;
364 328
365 // The MatchComplete status of the prerender, indicating how it relates
366 // to being a MatchComplete dummy (see definition of MatchCompleteStatus
367 // above).
368 MatchCompleteStatus match_complete_status_;
369
370 // Tracks whether or not prerendering has been cancelled by calling Destroy. 329 // Tracks whether or not prerendering has been cancelled by calling Destroy.
371 // Used solely to prevent double deletion. 330 // Used solely to prevent double deletion.
372 bool prerendering_has_been_cancelled_; 331 bool prerendering_has_been_cancelled_;
373 332
374 // Process Metrics of the render process associated with the 333 // Process Metrics of the render process associated with the
375 // RenderViewHost for this object. 334 // RenderViewHost for this object.
376 std::unique_ptr<base::ProcessMetrics> process_metrics_; 335 std::unique_ptr<base::ProcessMetrics> process_metrics_;
377 336
378 std::unique_ptr<WebContentsDelegateImpl> web_contents_delegate_; 337 std::unique_ptr<WebContentsDelegateImpl> web_contents_delegate_;
379 338
(...skipping 19 matching lines...) Expand all
399 // A running tally of the number of bytes this prerender has caused to be 358 // A running tally of the number of bytes this prerender has caused to be
400 // transferred over the network for resources. Updated with AddNetworkBytes. 359 // transferred over the network for resources. Updated with AddNetworkBytes.
401 int64_t network_bytes_; 360 int64_t network_bytes_;
402 361
403 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); 362 DISALLOW_COPY_AND_ASSIGN(PrerenderContents);
404 }; 363 };
405 364
406 } // namespace prerender 365 } // namespace prerender
407 366
408 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ 367 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_browsertest.cc ('k') | chrome/browser/prerender/prerender_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698