| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_RENDERER_LOAD_PROGRESS_TRACKER_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_LOAD_PROGRESS_TRACKER_H_ |
| 6 #define CONTENT_RENDERER_LOAD_PROGRESS_TRACKER_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_LOAD_PROGRESS_TRACKER_H_ |
| 7 | 7 |
| 8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
| 9 #include "base/gtest_prod_util.h" |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 class RenderViewImpl; | 15 class NavigatorDelegate; |
| 15 | 16 |
| 16 class LoadProgressTracker { | 17 class LoadProgressTracker { |
| 17 public: | 18 public: |
| 18 explicit LoadProgressTracker(RenderViewImpl* render_view); | 19 explicit LoadProgressTracker(NavigatorDelegate* delegate); |
| 19 ~LoadProgressTracker(); | 20 ~LoadProgressTracker(); |
| 20 | 21 |
| 21 void DidStartLoading(int frame_routing_id); | 22 void DidStartLoading(int frame_routing_id); |
| 22 void DidStopLoading(int frame_routing_id); | 23 void DidStopLoading(int frame_routing_id); |
| 23 | 24 |
| 24 void DidChangeLoadProgress(int frame_routing_id, double progress); | 25 void DidChangeLoadProgress(int frame_routing_id, double progress); |
| 25 | 26 |
| 26 private: | 27 private: |
| 28 FRIEND_TEST_ALL_PREFIXES(LoadProgressTrackerBrowserTest, BasicProgress); |
| 29 |
| 27 void ResetStates(); | 30 void ResetStates(); |
| 28 | 31 |
| 29 void SendChangeLoadProgress(); | 32 void SendChangeLoadProgress(); |
| 30 | 33 |
| 31 RenderViewImpl* render_view_; | 34 NavigatorDelegate* delegate_; |
| 32 | 35 |
| 33 // ProgressMap maps RenderFrame routing ids to a double representing that | 36 // ProgressMap maps RenderFrameHost routing ids to a double representing that |
| 34 // frame's completion (from 0 to 1). | 37 // frame's completion (from 0 to 1). |
| 35 typedef base::hash_map<int, double> ProgressMap; | 38 typedef base::hash_map<int, double> ProgressMap; |
| 36 ProgressMap progresses_; | 39 ProgressMap progresses_; |
| 37 double total_progress_; | 40 double total_progress_; |
| 38 | 41 |
| 39 base::TimeTicks last_time_progress_sent_; | 42 base::TimeTicks last_time_progress_sent_; |
| 40 | 43 |
| 41 base::WeakPtrFactory<LoadProgressTracker> weak_factory_; | 44 base::WeakPtrFactory<LoadProgressTracker> weak_factory_; |
| 42 | 45 |
| 43 DISALLOW_COPY_AND_ASSIGN(LoadProgressTracker); | 46 DISALLOW_COPY_AND_ASSIGN(LoadProgressTracker); |
| 44 }; | 47 }; |
| 45 | 48 |
| 46 } // namespace content | 49 } // namespace content |
| 47 | 50 |
| 48 #endif // CONTENT_RENDERER_LOAD_PROGRESS_TRACKER_H_ | 51 #endif // CONTENT_BROWSER_FRAME_HOST_LOAD_PROGRESS_TRACKER_H_ |
| OLD | NEW |