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> |
| 9 |
8 #include <string> | 10 #include <string> |
9 #include <utility> | 11 #include <utility> |
10 #include <vector> | 12 #include <vector> |
11 | 13 |
| 14 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
14 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
15 #include "base/time/time.h" | 18 #include "base/time/time.h" |
16 #include "base/values.h" | 19 #include "base/values.h" |
17 #include "chrome/browser/prerender/prerender_final_status.h" | 20 #include "chrome/browser/prerender/prerender_final_status.h" |
18 #include "chrome/browser/prerender/prerender_origin.h" | 21 #include "chrome/browser/prerender/prerender_origin.h" |
19 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
21 #include "content/public/browser/web_contents_observer.h" | 24 #include "content/public/browser/web_contents_observer.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // Marks prerender as used and releases any throttled resource requests. | 258 // Marks prerender as used and releases any throttled resource requests. |
256 void PrepareForUse(); | 259 void PrepareForUse(); |
257 | 260 |
258 // Called when a PrerenderResourceThrottle defers a request. If the prerender | 261 // Called when a PrerenderResourceThrottle defers a request. If the prerender |
259 // is used it'll be resumed on the IO thread, otherwise they will get | 262 // is used it'll be resumed on the IO thread, otherwise they will get |
260 // cancelled automatically if prerendering is cancelled. | 263 // cancelled automatically if prerendering is cancelled. |
261 void AddResourceThrottle( | 264 void AddResourceThrottle( |
262 const base::WeakPtr<PrerenderResourceThrottle>& throttle); | 265 const base::WeakPtr<PrerenderResourceThrottle>& throttle); |
263 | 266 |
264 // Increments the number of bytes fetched over the network for this prerender. | 267 // Increments the number of bytes fetched over the network for this prerender. |
265 void AddNetworkBytes(int64 bytes); | 268 void AddNetworkBytes(int64_t bytes); |
266 | 269 |
267 protected: | 270 protected: |
268 PrerenderContents(PrerenderManager* prerender_manager, | 271 PrerenderContents(PrerenderManager* prerender_manager, |
269 Profile* profile, | 272 Profile* profile, |
270 const GURL& url, | 273 const GURL& url, |
271 const content::Referrer& referrer, | 274 const content::Referrer& referrer, |
272 Origin origin); | 275 Origin origin); |
273 | 276 |
274 // Set the final status for how the PrerenderContents was used. This | 277 // Set the final status for how the PrerenderContents was used. This |
275 // should only be called once, and should be called before the prerender | 278 // should only be called once, and should be called before the prerender |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // the time elapsed from initiating a prerender until the time the | 310 // the time elapsed from initiating a prerender until the time the |
308 // (potentially only partially) prerendered page is shown to the user. | 311 // (potentially only partially) prerendered page is shown to the user. |
309 base::TimeTicks load_start_time_; | 312 base::TimeTicks load_start_time_; |
310 | 313 |
311 // The prerendered WebContents; may be null. | 314 // The prerendered WebContents; may be null. |
312 scoped_ptr<content::WebContents> prerender_contents_; | 315 scoped_ptr<content::WebContents> prerender_contents_; |
313 | 316 |
314 // The session storage namespace id for use in matching. We must save it | 317 // The session storage namespace id for use in matching. We must save it |
315 // rather than get it from the RenderViewHost since in the control group | 318 // rather than get it from the RenderViewHost since in the control group |
316 // we won't have a RenderViewHost. | 319 // we won't have a RenderViewHost. |
317 int64 session_storage_namespace_id_; | 320 int64_t session_storage_namespace_id_; |
318 | 321 |
319 private: | 322 private: |
320 class WebContentsDelegateImpl; | 323 class WebContentsDelegateImpl; |
321 | 324 |
322 // Needs to be able to call the constructor. | 325 // Needs to be able to call the constructor. |
323 friend class PrerenderContentsFactoryImpl; | 326 friend class PrerenderContentsFactoryImpl; |
324 | 327 |
325 // Returns the ProcessMetrics for the render process, if it exists. | 328 // Returns the ProcessMetrics for the render process, if it exists. |
326 base::ProcessMetrics* MaybeGetProcessMetrics(); | 329 base::ProcessMetrics* MaybeGetProcessMetrics(); |
327 | 330 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 395 |
393 // Caches pages to be added to the history. | 396 // Caches pages to be added to the history. |
394 AddPageVector add_page_vector_; | 397 AddPageVector add_page_vector_; |
395 | 398 |
396 // Resources that are throttled, pending a prerender use. Can only access a | 399 // Resources that are throttled, pending a prerender use. Can only access a |
397 // throttle on the IO thread. | 400 // throttle on the IO thread. |
398 std::vector<base::WeakPtr<PrerenderResourceThrottle> > resource_throttles_; | 401 std::vector<base::WeakPtr<PrerenderResourceThrottle> > resource_throttles_; |
399 | 402 |
400 // A running tally of the number of bytes this prerender has caused to be | 403 // A running tally of the number of bytes this prerender has caused to be |
401 // transferred over the network for resources. Updated with AddNetworkBytes. | 404 // transferred over the network for resources. Updated with AddNetworkBytes. |
402 int64 network_bytes_; | 405 int64_t network_bytes_; |
403 | 406 |
404 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 407 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
405 }; | 408 }; |
406 | 409 |
407 } // namespace prerender | 410 } // namespace prerender |
408 | 411 |
409 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 412 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
OLD | NEW |