Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(650)

Side by Side Diff: components/metrics/metrics_reporting_scheduler.h

Issue 979363003: UMA: use a more frequent upload interval for Chromecast. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adds upload interval to client Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_METRICS_METRICS_REPORTING_SCHEDULER_H_ 5 #ifndef COMPONENTS_METRICS_METRICS_REPORTING_SCHEDULER_H_
6 #define COMPONENTS_METRICS_METRICS_REPORTING_SCHEDULER_H_ 6 #define COMPONENTS_METRICS_METRICS_REPORTING_SCHEDULER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "components/metrics/net/network_metrics_provider.h" 13 #include "components/metrics/net/network_metrics_provider.h"
14 14
15 namespace metrics { 15 namespace metrics {
16 16
17 // Scheduler task to drive a MetricsService object's uploading. 17 // Scheduler task to drive a MetricsService object's uploading.
18 class MetricsReportingScheduler { 18 class MetricsReportingScheduler {
19 public: 19 public:
20 // Creates MetricsServiceScheduler object with the given |upload_callback| 20 // Creates MetricsServiceScheduler object with the given |upload_callback|
21 // callback to call when uploading should happen and |cellular_callback| 21 // callback to call when uploading should happen and
22 // callback to get current network connection type. 22 // |upload_interval_callback| to determine the interval between uploads
23 // in steady state.
23 MetricsReportingScheduler( 24 MetricsReportingScheduler(
24 const base::Closure& upload_callback, 25 const base::Closure& upload_callback,
25 const base::Callback<void(bool*)>& cellular_callback); 26 const base::Callback<base::TimeDelta(void)>& upload_interval_callback);
26 ~MetricsReportingScheduler(); 27 ~MetricsReportingScheduler();
27 28
28 // Starts scheduling uploads. This in a no-op if the scheduler is already 29 // Starts scheduling uploads. This in a no-op if the scheduler is already
29 // running, so it is safe to call more than once. 30 // running, so it is safe to call more than once.
30 void Start(); 31 void Start();
31 32
32 // Stops scheduling uploads. 33 // Stops scheduling uploads.
33 void Stop(); 34 void Stop();
34 35
35 // Callback from MetricsService when the startup init task has completed. 36 // Callback from MetricsService when the startup init task has completed.
(...skipping 14 matching lines...) Expand all
50 // metrics. 51 // metrics.
51 void TriggerUpload(); 52 void TriggerUpload();
52 53
53 // Schedules a future call to TriggerUpload if one isn't already pending. 54 // Schedules a future call to TriggerUpload if one isn't already pending.
54 void ScheduleNextUpload(); 55 void ScheduleNextUpload();
55 56
56 // Increases the upload interval each time it's called, to handle the case 57 // Increases the upload interval each time it's called, to handle the case
57 // where the server is having issues. 58 // where the server is having issues.
58 void BackOffUploadInterval(); 59 void BackOffUploadInterval();
59 60
60 // Returns upload interval based on the system and experiment that the user is 61 // Returns upload interval to use in steady state.
61 // assigned to. 62 base::TimeDelta GetStandardUploadInterval();
63
64 // Returns upload interval specified for the current experiment running.
62 // TODO(gayane): Only for experimenting with upload interval for Android 65 // TODO(gayane): Only for experimenting with upload interval for Android
63 // (bug: 17391128). Should be removed once the experiments are done. 66 // (bug: 17391128). Should be removed once the experiments are done.
64 base::TimeDelta GetStandardUploadInterval(); 67 base::TimeDelta GetUploadIntervalFromExperiment();
Alexei Svitkine (slow) 2015/03/09 17:26:17 This can be removed - see my other comment.
gunsch 2015/03/13 00:50:12 Done.
65 68
66 // The MetricsService method to call when uploading should happen. 69 // The MetricsService method to call when uploading should happen.
67 const base::Closure upload_callback_; 70 const base::Closure upload_callback_;
68 71
69 base::OneShotTimer<MetricsReportingScheduler> upload_timer_; 72 base::OneShotTimer<MetricsReportingScheduler> upload_timer_;
70 73
71 // The interval between being told an upload is done and starting the next 74 // The interval between being told an upload is done and starting the next
72 // upload. 75 // upload.
73 base::TimeDelta upload_interval_; 76 base::TimeDelta upload_interval_;
74 77
75 // The tick count of the last time log upload has been finished and null if no 78 // The tick count of the last time log upload has been finished and null if no
76 // upload has been done yet. 79 // upload has been done yet.
77 base::TimeTicks last_upload_finish_time_; 80 base::TimeTicks last_upload_finish_time_;
78 81
79 // Indicates that the scheduler is running (i.e., that Start has been called 82 // Indicates that the scheduler is running (i.e., that Start has been called
80 // more recently than Stop). 83 // more recently than Stop).
81 bool running_; 84 bool running_;
82 85
83 // Indicates that the last triggered upload hasn't resolved yet. 86 // Indicates that the last triggered upload hasn't resolved yet.
84 bool callback_pending_; 87 bool callback_pending_;
85 88
86 // Whether the InitTaskComplete() callback has been called. 89 // Whether the InitTaskComplete() callback has been called.
87 bool init_task_complete_; 90 bool init_task_complete_;
88 91
89 // Whether the initial scheduled upload timer has fired before the init task 92 // Whether the initial scheduled upload timer has fired before the init task
90 // has been completed. 93 // has been completed.
91 bool waiting_for_init_task_complete_; 94 bool waiting_for_init_task_complete_;
92 95
93 // Callback function used to get current network connection type. 96 // Callback function used to get the standard upload time.
94 base::Callback<void(bool*)> cellular_callback_; 97 base::Callback<base::TimeDelta(void)> upload_interval_callback_;
95 98
96 DISALLOW_COPY_AND_ASSIGN(MetricsReportingScheduler); 99 DISALLOW_COPY_AND_ASSIGN(MetricsReportingScheduler);
97 }; 100 };
98 101
99 } // namespace metrics 102 } // namespace metrics
100 103
101 #endif // COMPONENTS_METRICS_METRICS_REPORTING_SCHEDULER_H_ 104 #endif // COMPONENTS_METRICS_METRICS_REPORTING_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698