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

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

Issue 2711693002: [Offline Pages] Make prerenderer notify us of network progress. (Closed)
Patch Set: last minute fixes Created 3 years, 10 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 // Running byte count. Increased when each resource completes loading.
246 int64_t network_bytes() { return network_bytes_; }
247
241 protected: 248 protected:
242 PrerenderContents(PrerenderManager* prerender_manager, 249 PrerenderContents(PrerenderManager* prerender_manager,
243 Profile* profile, 250 Profile* profile,
244 const GURL& url, 251 const GURL& url,
245 const content::Referrer& referrer, 252 const content::Referrer& referrer,
246 Origin origin); 253 Origin origin);
247 254
248 // Set the final status for how the PrerenderContents was used. This 255 // Set the final status for how the PrerenderContents was used. This
249 // should only be called once, and should be called before the prerender 256 // should only be called once, and should be called before the prerender
250 // contents are destroyed. 257 // contents are destroyed.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 int64_t network_bytes_; 378 int64_t network_bytes_;
372 379
373 base::WeakPtrFactory<PrerenderContents> weak_factory_; 380 base::WeakPtrFactory<PrerenderContents> weak_factory_;
374 381
375 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); 382 DISALLOW_COPY_AND_ASSIGN(PrerenderContents);
376 }; 383 };
377 384
378 } // namespace prerender 385 } // namespace prerender
379 386
380 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ 387 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698