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

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: Rebased to trunk 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
« no previous file with comments | « no previous file | chrome/browser/metrics/metrics_reporting_scheduler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/callback.h"
11 #include "base/task.h"
12
13 // Scheduler task to drive a MetricsService object's uploading.
14 class MetricsReportingScheduler {
15 public:
16 explicit MetricsReportingScheduler(const base::Closure& upload_callback);
17 ~MetricsReportingScheduler();
18
19 // Starts scheduling uploads. This in a no-op if the scheduler is already
20 // running, so it is safe to call more than once.
21 void Start();
22
23 // Stops scheduling uploads.
24 void Stop();
25
26 // Callback from MetricsService when a triggered upload finishes.
27 void UploadFinished(bool server_is_healthy, bool more_logs_remaining);
28
29 // Callback from MetricsService when a triggered upload is cancelled by the
30 // MetricsService.
31 void UploadCancelled();
32
33 private:
34 // Timer callback indicating it's time for the MetricsService to upload
35 // metrics.
36 void TriggerUpload();
37
38 // Schedules a future call to TriggerUpload if one isn't already pending.
39 void ScheduleNextCallback();
40
41 // Increases the upload interval each time it's called, to handle the case
42 // where the server is having issues.
43 void BackOffUploadInterval();
44
45 // The MetricsService method to call when uploading should happen.
46 base::Closure upload_callback_;
47
48 ScopedRunnableMethodFactory<MetricsReportingScheduler> upload_timer_factory_;
49
50 // The interval between being told an upload is done and starting the next
51 // upload.
52 base::TimeDelta upload_interval_;
53
54 // Indicates that the scheduler is running (i.e., that Start has been called
55 // more recently than Stop).
56 bool running_;
57
58 // Indicates that a timer for triggering the next upload has already been
59 // started.
60 bool timer_pending_;
61
62 // Indicates that the last triggered upload hasn't resolved yet.
63 bool callback_pending_;
64
65 DISALLOW_COPY_AND_ASSIGN(MetricsReportingScheduler);
66 };
67
68 #endif // CHROME_BROWSER_METRICS_METRICS_REPORTING_SCHEDULER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/metrics_reporting_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698