Remove unused did_first_* fields from InternalDocumentStateData.
[chromium-blink-merge.git] / remoting / client / chromoting_stats.h
blob5e8a93b497caccfa6ae99d62b76ab56afd4350ba
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 // ChromotingStats defines a bundle of performance counters and statistics
6 // for chromoting.
8 #ifndef REMOTING_CLIENT_CHROMOTING_STATS_H_
9 #define REMOTING_CLIENT_CHROMOTING_STATS_H_
11 #include "base/callback.h"
12 #include "remoting/base/rate_counter.h"
13 #include "remoting/base/running_average.h"
15 namespace remoting {
17 class VideoPacket;
19 class ChromotingStats {
20 public:
21 // Callback that updates UMA custom counts or custom times histograms.
22 typedef base::Callback<void(const std::string& histogram_name,
23 int64 value,
24 int histogram_min,
25 int histogram_max,
26 int histogram_buckets)>
27 UpdateUmaCustomHistogramCallback;
29 // Callback that updates UMA enumeration histograms.
30 typedef base::Callback<
31 void(const std::string& histogram_name, int64 value, int histogram_max)>
32 UpdateUmaEnumHistogramCallback;
34 ChromotingStats();
35 virtual ~ChromotingStats();
37 // Constant used to calculate the average for rate metrics and used by the
38 // plugin for the frequency at which stats should be updated.
39 static const int kStatsUpdateFrequencyInSeconds = 1;
41 // Return rates and running-averages for different metrics.
42 double video_bandwidth() { return video_bandwidth_.Rate(); }
43 double video_frame_rate() { return video_frame_rate_.Rate(); }
44 double video_packet_rate() { return video_packet_rate_.Rate(); }
45 double video_capture_ms() { return video_capture_ms_.Average(); }
46 double video_encode_ms() { return video_encode_ms_.Average(); }
47 double video_decode_ms() { return video_decode_ms_.Average(); }
48 double video_paint_ms() { return video_paint_ms_.Average(); }
49 double round_trip_ms() { return round_trip_ms_.Average(); }
51 // Record stats for a video-packet.
52 void RecordVideoPacketStats(const VideoPacket& packet);
54 void RecordDecodeTime(double value);
55 void RecordPaintTime(double value);
57 // Sets callbacks in ChromotingInstance to update a UMA custom counts, custom
58 // times or enum histogram.
59 void SetUpdateUmaCallbacks(
60 UpdateUmaCustomHistogramCallback update_uma_custom_counts_callback,
61 UpdateUmaCustomHistogramCallback update_uma_custom_times_callback,
62 UpdateUmaEnumHistogramCallback update_uma_enum_histogram_callback);
64 // Updates frame-rate, packet-rate and bandwidth UMA statistics.
65 void UploadRateStatsToUma();
67 private:
68 // The video and packet rate metrics below are updated per video packet
69 // received and then, for reporting, averaged over a 1s time-window.
70 // Bytes per second for non-empty video-packets.
71 RateCounter video_bandwidth_;
73 // Frames per second for non-empty video-packets.
74 RateCounter video_frame_rate_;
76 // Video packets per second, including empty video-packets.
77 // This will be greater than the frame rate, as individual frames are
78 // contained in packets, some of which might be empty (e.g. when there are no
79 // screen changes).
80 RateCounter video_packet_rate_;
82 // The following running-averages are uploaded to UMA per video packet and
83 // also used for display to users, averaged over the N most recent samples.
84 // N = kLatencySampleSize.
85 RunningAverage video_capture_ms_;
86 RunningAverage video_encode_ms_;
87 RunningAverage video_decode_ms_;
88 RunningAverage video_paint_ms_;
89 RunningAverage round_trip_ms_;
91 // Used to update UMA stats, if set.
92 UpdateUmaCustomHistogramCallback uma_custom_counts_updater_;
93 UpdateUmaCustomHistogramCallback uma_custom_times_updater_;
94 UpdateUmaEnumHistogramCallback uma_enum_histogram_updater_;
96 // The latest input timestamp that a VideoPacket was seen annotated with.
97 int64 latest_input_event_timestamp_ = 0;
99 DISALLOW_COPY_AND_ASSIGN(ChromotingStats);
102 } // namespace remoting
104 #endif // REMOTING_CLIENT_CHROMOTING_STATS_H_