OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_RENDERER_LOAD_PROGRESS_TRACKER_H_ | |
6 #define CONTENT_RENDERER_LOAD_PROGRESS_TRACKER_H_ | |
7 | |
8 #include "base/containers/hash_tables.h" | |
9 #include "base/logging.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "base/time/time.h" | |
12 | |
13 namespace content { | |
14 class RenderViewImpl; | |
15 | |
16 class LoadProgressTracker { | |
17 public: | |
18 explicit LoadProgressTracker(RenderViewImpl* render_view); | |
19 ~LoadProgressTracker(); | |
20 | |
21 void DidStartLoading(int frame_routing_id); | |
22 void DidStopLoading(int frame_routing_id); | |
23 | |
24 void DidChangeLoadProgress(int frame_routing_id, double progress); | |
25 | |
26 private: | |
27 void ResetStates(); | |
28 | |
29 void SendChangeLoadProgress(); | |
30 | |
31 RenderViewImpl* render_view_; | |
32 | |
33 // ProgressMap maps RenderFrame routing ids to a double representing that | |
34 // frame's completion (from 0 to 1). | |
35 typedef base::hash_map<int, double> ProgressMap; | |
36 ProgressMap progresses_; | |
37 double total_progress_; | |
38 | |
39 base::TimeTicks last_time_progress_sent_; | |
40 | |
41 base::WeakPtrFactory<LoadProgressTracker> weak_factory_; | |
42 | |
43 DISALLOW_COPY_AND_ASSIGN(LoadProgressTracker); | |
44 }; | |
45 | |
46 } // namespace content | |
47 | |
48 #endif // CONTENT_RENDERER_LOAD_PROGRESS_TRACKER_H_ | |
OLD | NEW |