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 #include "content/renderer/load_progress_tracker.h" | 5 #include "content/renderer/load_progress_tracker.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "content/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
10 #include "content/renderer/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 weak_factory_.InvalidateWeakPtrs(); | 61 weak_factory_.InvalidateWeakPtrs(); |
62 SendChangeLoadProgress(); | 62 SendChangeLoadProgress(); |
63 if (progress == 1.0) | 63 if (progress == 1.0) |
64 ResetStates(); | 64 ResetStates(); |
65 return; | 65 return; |
66 } | 66 } |
67 | 67 |
68 if (weak_factory_.HasWeakPtrs()) | 68 if (weak_factory_.HasWeakPtrs()) |
69 return; | 69 return; |
70 | 70 |
71 MessageLoop::current()->PostDelayedTask( | 71 base::MessageLoop::current()->PostDelayedTask( |
72 FROM_HERE, | 72 FROM_HERE, |
73 base::Bind(&LoadProgressTracker::SendChangeLoadProgress, | 73 base::Bind(&LoadProgressTracker::SendChangeLoadProgress, |
74 weak_factory_.GetWeakPtr()), | 74 weak_factory_.GetWeakPtr()), |
75 min_delay); | 75 min_delay); |
76 } | 76 } |
77 | 77 |
78 void LoadProgressTracker::SendChangeLoadProgress() { | 78 void LoadProgressTracker::SendChangeLoadProgress() { |
79 last_time_progress_sent_ = base::TimeTicks::Now(); | 79 last_time_progress_sent_ = base::TimeTicks::Now(); |
80 render_view_->Send( | 80 render_view_->Send( |
81 new ViewHostMsg_DidChangeLoadProgress(render_view_->routing_id(), | 81 new ViewHostMsg_DidChangeLoadProgress(render_view_->routing_id(), |
82 progress_)); | 82 progress_)); |
83 } | 83 } |
84 | 84 |
85 void LoadProgressTracker::ResetStates() { | 85 void LoadProgressTracker::ResetStates() { |
86 tracked_frame_ = NULL; | 86 tracked_frame_ = NULL; |
87 progress_ = 0.0; | 87 progress_ = 0.0; |
88 weak_factory_.InvalidateWeakPtrs(); | 88 weak_factory_.InvalidateWeakPtrs(); |
89 last_time_progress_sent_ = base::TimeTicks(); | 89 last_time_progress_sent_ = base::TimeTicks(); |
90 } | 90 } |
91 | 91 |
92 } // namespace content | 92 } // namespace content |
OLD | NEW |