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.
5 #ifndef CONTENT_RENDERER_LOAD_PROGRESS_TRACKER_H_
6 #define CONTENT_RENDERER_LOAD_PROGRESS_TRACKER_H_
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"
16 class LoadProgressTracker
{
18 explicit LoadProgressTracker(RenderViewImpl
* render_view
);
19 ~LoadProgressTracker();
21 void DidStartLoading(int frame_routing_id
);
22 void DidStopLoading(int frame_routing_id
);
24 void DidChangeLoadProgress(int frame_routing_id
, double progress
);
29 void SendChangeLoadProgress();
31 RenderViewImpl
* render_view_
;
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_
;
39 base::TimeTicks last_time_progress_sent_
;
41 base::WeakPtrFactory
<LoadProgressTracker
> weak_factory_
;
43 DISALLOW_COPY_AND_ASSIGN(LoadProgressTracker
);
46 } // namespace content
48 #endif // CONTENT_RENDERER_LOAD_PROGRESS_TRACKER_H_