| 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> |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 virtual void OnPrerenderStopLoading(PrerenderContents* contents) {} | 82 virtual void OnPrerenderStopLoading(PrerenderContents* contents) {} |
| 83 | 83 |
| 84 // Signals that the prerender has had its 'DOMContentLoaded' event. | 84 // Signals that the prerender has had its 'DOMContentLoaded' event. |
| 85 virtual void OnPrerenderDomContentLoaded(PrerenderContents* contents) {} | 85 virtual void OnPrerenderDomContentLoaded(PrerenderContents* contents) {} |
| 86 | 86 |
| 87 // Signals that the prerender has stopped running. A PrerenderContents with | 87 // Signals that the prerender has stopped running. A PrerenderContents with |
| 88 // an unset final status will always call OnPrerenderStop before being | 88 // an unset final status will always call OnPrerenderStop before being |
| 89 // destroyed. | 89 // destroyed. |
| 90 virtual void OnPrerenderStop(PrerenderContents* contents) {} | 90 virtual void OnPrerenderStop(PrerenderContents* contents) {} |
| 91 | 91 |
| 92 // Signals that a resource finished loading and altered the running byte |
| 93 // count. |
| 94 virtual void OnPrerenderNetworkBytesChanged(PrerenderContents* contents) {} |
| 95 |
| 92 protected: | 96 protected: |
| 93 Observer() {} | 97 Observer() {} |
| 94 virtual ~Observer() = 0; | 98 virtual ~Observer() = 0; |
| 95 }; | 99 }; |
| 96 | 100 |
| 97 ~PrerenderContents() override; | 101 ~PrerenderContents() override; |
| 98 | 102 |
| 99 // All observers of a PrerenderContents are removed after the OnPrerenderStop | 103 // All observers of a PrerenderContents are removed after the OnPrerenderStop |
| 100 // event is sent, so there is no need to call RemoveObserver() in the normal | 104 // event is sent, so there is no need to call RemoveObserver() in the normal |
| 101 // use case. | 105 // use case. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 void AddResourceThrottle( | 235 void AddResourceThrottle( |
| 232 const base::WeakPtr<PrerenderResourceThrottle>& throttle); | 236 const base::WeakPtr<PrerenderResourceThrottle>& throttle); |
| 233 | 237 |
| 234 // Increments the number of bytes fetched over the network for this prerender. | 238 // Increments the number of bytes fetched over the network for this prerender. |
| 235 void AddNetworkBytes(int64_t bytes); | 239 void AddNetworkBytes(int64_t bytes); |
| 236 | 240 |
| 237 bool prerendering_has_been_cancelled() const { | 241 bool prerendering_has_been_cancelled() const { |
| 238 return prerendering_has_been_cancelled_; | 242 return prerendering_has_been_cancelled_; |
| 239 } | 243 } |
| 240 | 244 |
| 245 int64_t network_bytes() { return network_bytes_; } |
| 246 |
| 241 protected: | 247 protected: |
| 242 PrerenderContents(PrerenderManager* prerender_manager, | 248 PrerenderContents(PrerenderManager* prerender_manager, |
| 243 Profile* profile, | 249 Profile* profile, |
| 244 const GURL& url, | 250 const GURL& url, |
| 245 const content::Referrer& referrer, | 251 const content::Referrer& referrer, |
| 246 Origin origin); | 252 Origin origin); |
| 247 | 253 |
| 248 // Set the final status for how the PrerenderContents was used. This | 254 // Set the final status for how the PrerenderContents was used. This |
| 249 // should only be called once, and should be called before the prerender | 255 // should only be called once, and should be called before the prerender |
| 250 // contents are destroyed. | 256 // contents are destroyed. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 int64_t network_bytes_; | 377 int64_t network_bytes_; |
| 372 | 378 |
| 373 base::WeakPtrFactory<PrerenderContents> weak_factory_; | 379 base::WeakPtrFactory<PrerenderContents> weak_factory_; |
| 374 | 380 |
| 375 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 381 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
| 376 }; | 382 }; |
| 377 | 383 |
| 378 } // namespace prerender | 384 } // namespace prerender |
| 379 | 385 |
| 380 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 386 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
| OLD | NEW |