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

Side by Side Diff: chrome/browser/metrics/metrics_reporting_scheduler.h

Issue 6869034: Factor a scheduler object out of MetricsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fix Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_METRICS_METRICS_REPORTING_SCHEDULER_H_
6 #define CHROME_BROWSER_METRICS_METRICS_REPORTING_SCHEDULER_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/task.h"
11
12 class MetricsService;
13
14 // Scheduler task to drive a MetricsService object's uploading.
15 class MetricsReportingScheduler {
16 public:
17 explicit MetricsReportingScheduler(MetricsService* metrics_service);
18 virtual ~MetricsReportingScheduler();
jar (doing other things) 2011/04/16 02:03:13 Why the virtual destructor? There is no base, and
stuartmorgan 2011/04/18 17:03:00 Just habit; removed.
19
20 // Starts scheduling uploads. This in a no-op if the scheduler is already
21 // running, so it is safe to call more than once.
22 void Start();
23
24 // Stops scheduling uploads.
25 void Stop();
26
27 // Callback from MetricsService when a triggered upload finishes.
28 void UploadFinished(bool server_is_healthy, bool more_logs_remaining);
29
30 // Callback from MetricsService when a triggered upload is cancelled by the
31 // MetricsService.
32 void UploadCancelled();
33
34 private:
35 // Timer callback indicating it's time for the MetricsService to upload
36 // metrics.
37 void TriggerUpload();
38
39 // Schedules a future call to TriggerUpload if one isn't already pending.
40 void ScheduleNextCallback();
41
42 // Increases the upload interval each time it's called, to handle the case
43 // where the server is having issues.
44 void BackOffUploadInterval();
45
46 // Weak reference to the MetricsService being scheduled.
47 MetricsService* metrics_service_;
48
49 ScopedRunnableMethodFactory<MetricsReportingScheduler> upload_timer_factory_;
50
51 // The interval between being told an upload is done and starting the next
52 // upload.
53 base::TimeDelta upload_interval_;
54
55 // Indicates that the scheduler is running (i.e., that Start has been called
56 // more recently than Stop).
57 bool running_;
58
59 // Indicates that a timer for triggering the next upload has already been
60 // started.
61 bool timer_pending_;
62
63 // Indicates that the last triggered upload hasn't resolved yet.
64 bool callback_pending_;
65
66 DISALLOW_COPY_AND_ASSIGN(MetricsReportingScheduler);
67 };
68
69 #endif // CHROME_BROWSER_METRICS_METRICS_REPORTING_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698