| 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 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <utility> | 12 #include <utility> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chrome/browser/prerender/prerender_final_status.h" | 20 #include "chrome/browser/prerender/prerender_final_status.h" |
| 21 #include "chrome/browser/prerender/prerender_origin.h" | 21 #include "chrome/browser/prerender/prerender_origin.h" |
| 22 #include "chrome/common/prerender_types.h" |
| 22 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
| 24 #include "content/public/browser/web_contents_observer.h" | 25 #include "content/public/browser/web_contents_observer.h" |
| 25 #include "content/public/common/referrer.h" | 26 #include "content/public/common/referrer.h" |
| 26 #include "ui/gfx/geometry/size.h" | 27 #include "ui/gfx/geometry/size.h" |
| 27 | 28 |
| 28 class Profile; | 29 class Profile; |
| 29 | 30 |
| 30 namespace base { | 31 namespace base { |
| 31 class ProcessMetrics; | 32 class ProcessMetrics; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 ~PrerenderContents() override; | 95 ~PrerenderContents() override; |
| 95 | 96 |
| 96 // All observers of a PrerenderContents are removed after the OnPrerenderStop | 97 // All observers of a PrerenderContents are removed after the OnPrerenderStop |
| 97 // event is sent, so there is no need to call RemoveObserver() in the normal | 98 // event is sent, so there is no need to call RemoveObserver() in the normal |
| 98 // use case. | 99 // use case. |
| 99 void AddObserver(Observer* observer); | 100 void AddObserver(Observer* observer); |
| 100 void RemoveObserver(Observer* observer); | 101 void RemoveObserver(Observer* observer); |
| 101 | 102 |
| 102 bool Init(); | 103 bool Init(); |
| 103 | 104 |
| 105 // Set the mode of this contents. This must be called before prerender has |
| 106 // started. |
| 107 void SetPrerenderMode(PrerenderMode mode); |
| 108 PrerenderMode prerender_mode() const { return prerender_mode_; } |
| 109 |
| 104 static Factory* CreateFactory(); | 110 static Factory* CreateFactory(); |
| 105 | 111 |
| 106 // Returns a PrerenderContents from the given web_contents, if it's used for | 112 // Returns a PrerenderContents from the given web_contents, if it's used for |
| 107 // prerendering. Otherwise returns NULL. Handles a NULL input for | 113 // prerendering. Otherwise returns NULL. Handles a NULL input for |
| 108 // convenience. | 114 // convenience. |
| 109 static PrerenderContents* FromWebContents(content::WebContents* web_contents); | 115 static PrerenderContents* FromWebContents(content::WebContents* web_contents); |
| 110 | 116 |
| 111 // Start rendering the contents in the prerendered state. If | 117 // Start rendering the contents in the prerendered state. If |
| 112 // |is_control_group| is true, this will go through some of the mechanics of | 118 // |is_control_group| is true, this will go through some of the mechanics of |
| 113 // starting a prerender, without actually creating the RenderView. |size| | 119 // starting a prerender, without actually creating the RenderView. |size| |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 return notification_registrar_; | 263 return notification_registrar_; |
| 258 } | 264 } |
| 259 | 265 |
| 260 bool prerendering_has_been_cancelled() const { | 266 bool prerendering_has_been_cancelled() const { |
| 261 return prerendering_has_been_cancelled_; | 267 return prerendering_has_been_cancelled_; |
| 262 } | 268 } |
| 263 | 269 |
| 264 content::WebContents* CreateWebContents( | 270 content::WebContents* CreateWebContents( |
| 265 content::SessionStorageNamespace* session_storage_namespace); | 271 content::SessionStorageNamespace* session_storage_namespace); |
| 266 | 272 |
| 273 PrerenderMode prerender_mode_; |
| 267 bool prerendering_has_started_; | 274 bool prerendering_has_started_; |
| 268 | 275 |
| 269 // Time at which we started to load the URL. This is used to compute | 276 // Time at which we started to load the URL. This is used to compute |
| 270 // the time elapsed from initiating a prerender until the time the | 277 // the time elapsed from initiating a prerender until the time the |
| 271 // (potentially only partially) prerendered page is shown to the user. | 278 // (potentially only partially) prerendered page is shown to the user. |
| 272 base::TimeTicks load_start_time_; | 279 base::TimeTicks load_start_time_; |
| 273 | 280 |
| 274 // The prerendered WebContents; may be null. | 281 // The prerendered WebContents; may be null. |
| 275 std::unique_ptr<content::WebContents> prerender_contents_; | 282 std::unique_ptr<content::WebContents> prerender_contents_; |
| 276 | 283 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 // A running tally of the number of bytes this prerender has caused to be | 365 // A running tally of the number of bytes this prerender has caused to be |
| 359 // transferred over the network for resources. Updated with AddNetworkBytes. | 366 // transferred over the network for resources. Updated with AddNetworkBytes. |
| 360 int64_t network_bytes_; | 367 int64_t network_bytes_; |
| 361 | 368 |
| 362 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 369 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
| 363 }; | 370 }; |
| 364 | 371 |
| 365 } // namespace prerender | 372 } // namespace prerender |
| 366 | 373 |
| 367 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 374 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
| OLD | NEW |