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_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 <stdint.h> |
| 9 |
8 #include <list> | 10 #include <list> |
9 #include <string> | 11 #include <string> |
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/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
14 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
15 #include "base/threading/non_thread_safe.h" | 18 #include "base/threading/non_thread_safe.h" |
16 #include "base/time/time.h" | 19 #include "base/time/time.h" |
17 #include "base/timer/timer.h" | 20 #include "base/timer/timer.h" |
18 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 21 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
19 #include "chrome/browser/prerender/prerender_config.h" | 22 #include "chrome/browser/prerender/prerender_config.h" |
20 #include "chrome/browser/prerender/prerender_contents.h" | 23 #include "chrome/browser/prerender/prerender_contents.h" |
21 #include "chrome/browser/prerender/prerender_final_status.h" | 24 #include "chrome/browser/prerender/prerender_final_status.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // Adds a prerender for |url| if valid. |process_id| and |route_id| identify | 102 // Adds a prerender for |url| if valid. |process_id| and |route_id| identify |
100 // the RenderView that the prerender request came from. If |size| is empty, a | 103 // the RenderView that the prerender request came from. If |size| is empty, a |
101 // default from the PrerenderConfig is used. Returns a caller-owned | 104 // default from the PrerenderConfig is used. Returns a caller-owned |
102 // PrerenderHandle* if the URL was added, NULL if it was not. If the launching | 105 // PrerenderHandle* if the URL was added, NULL if it was not. If the launching |
103 // RenderView is itself prerendering, the prerender is added as a pending | 106 // RenderView is itself prerendering, the prerender is added as a pending |
104 // prerender. | 107 // prerender. |
105 PrerenderHandle* AddPrerenderFromLinkRelPrerender( | 108 PrerenderHandle* AddPrerenderFromLinkRelPrerender( |
106 int process_id, | 109 int process_id, |
107 int route_id, | 110 int route_id, |
108 const GURL& url, | 111 const GURL& url, |
109 uint32 rel_types, | 112 uint32_t rel_types, |
110 const content::Referrer& referrer, | 113 const content::Referrer& referrer, |
111 const gfx::Size& size); | 114 const gfx::Size& size); |
112 | 115 |
113 // Adds a prerender for |url| if valid. As the prerender request is coming | 116 // Adds a prerender for |url| if valid. As the prerender request is coming |
114 // from a source without a RenderFrameHost (i.e., the omnibox) we don't have a | 117 // from a source without a RenderFrameHost (i.e., the omnibox) we don't have a |
115 // child or route id, or a referrer. This method uses sensible values for | 118 // child or route id, or a referrer. This method uses sensible values for |
116 // those. The |session_storage_namespace| matches the namespace of the active | 119 // those. The |session_storage_namespace| matches the namespace of the active |
117 // tab at the time the prerender is generated from the omnibox. Returns a | 120 // tab at the time the prerender is generated from the omnibox. Returns a |
118 // caller-owned PrerenderHandle*, or NULL. | 121 // caller-owned PrerenderHandle*, or NULL. |
119 PrerenderHandle* AddPrerenderFromOmnibox( | 122 PrerenderHandle* AddPrerenderFromOmnibox( |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 Profile* profile() const { return profile_; } | 264 Profile* profile() const { return profile_; } |
262 | 265 |
263 // Classes which will be tested in prerender unit browser tests should use | 266 // Classes which will be tested in prerender unit browser tests should use |
264 // these methods to get times for comparison, so that the test framework can | 267 // these methods to get times for comparison, so that the test framework can |
265 // mock advancing/retarding time. | 268 // mock advancing/retarding time. |
266 virtual base::Time GetCurrentTime() const; | 269 virtual base::Time GetCurrentTime() const; |
267 virtual base::TimeTicks GetCurrentTimeTicks() const; | 270 virtual base::TimeTicks GetCurrentTimeTicks() const; |
268 | 271 |
269 // Notification that a prerender has completed and its bytes should be | 272 // Notification that a prerender has completed and its bytes should be |
270 // recorded. | 273 // recorded. |
271 void RecordNetworkBytes(Origin origin, bool used, int64 prerender_bytes); | 274 void RecordNetworkBytes(Origin origin, bool used, int64_t prerender_bytes); |
272 | 275 |
273 // Returns whether prerendering is currently enabled for this manager. | 276 // Returns whether prerendering is currently enabled for this manager. |
274 bool IsEnabled() const; | 277 bool IsEnabled() const; |
275 | 278 |
276 // Add to the running tally of bytes transferred over the network for this | 279 // Add to the running tally of bytes transferred over the network for this |
277 // profile if prerendering is currently enabled. | 280 // profile if prerendering is currently enabled. |
278 void AddProfileNetworkBytesIfEnabled(int64 bytes); | 281 void AddProfileNetworkBytesIfEnabled(int64_t bytes); |
279 | 282 |
280 // Registers a new ProcessHost performing a prerender. Called by | 283 // Registers a new ProcessHost performing a prerender. Called by |
281 // PrerenderContents. | 284 // PrerenderContents. |
282 void AddPrerenderProcessHost(content::RenderProcessHost* process_host); | 285 void AddPrerenderProcessHost(content::RenderProcessHost* process_host); |
283 | 286 |
284 // Returns whether or not |process_host| may be reused for new navigations | 287 // Returns whether or not |process_host| may be reused for new navigations |
285 // from a prerendering perspective. Currently, if Prerender Cookie Stores are | 288 // from a prerendering perspective. Currently, if Prerender Cookie Stores are |
286 // enabled, prerenders must be in their own processes that may not be shared. | 289 // enabled, prerenders must be in their own processes that may not be shared. |
287 bool MayReuseProcessHost(content::RenderProcessHost* process_host); | 290 bool MayReuseProcessHost(content::RenderProcessHost* process_host); |
288 | 291 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 ScopedVector<OnCloseWebContentsDeleter> on_close_web_contents_deleters_; | 521 ScopedVector<OnCloseWebContentsDeleter> on_close_web_contents_deleters_; |
519 | 522 |
520 scoped_ptr<PrerenderHistory> prerender_history_; | 523 scoped_ptr<PrerenderHistory> prerender_history_; |
521 | 524 |
522 scoped_ptr<PrerenderHistograms> histograms_; | 525 scoped_ptr<PrerenderHistograms> histograms_; |
523 | 526 |
524 content::NotificationRegistrar notification_registrar_; | 527 content::NotificationRegistrar notification_registrar_; |
525 | 528 |
526 // The number of bytes transferred over the network for the profile this | 529 // The number of bytes transferred over the network for the profile this |
527 // PrerenderManager is attached to. | 530 // PrerenderManager is attached to. |
528 int64 profile_network_bytes_; | 531 int64_t profile_network_bytes_; |
529 | 532 |
530 // The value of profile_network_bytes_ that was last recorded. | 533 // The value of profile_network_bytes_ that was last recorded. |
531 int64 last_recorded_profile_network_bytes_; | 534 int64_t last_recorded_profile_network_bytes_; |
532 | 535 |
533 // Set of process hosts being prerendered. | 536 // Set of process hosts being prerendered. |
534 typedef std::set<content::RenderProcessHost*> PrerenderProcessSet; | 537 typedef std::set<content::RenderProcessHost*> PrerenderProcessSet; |
535 PrerenderProcessSet prerender_process_hosts_; | 538 PrerenderProcessSet prerender_process_hosts_; |
536 | 539 |
537 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 540 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
538 }; | 541 }; |
539 | 542 |
540 } // namespace prerender | 543 } // namespace prerender |
541 | 544 |
542 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 545 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |