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

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

Issue 7001003: Switch MetricsReportingScheduler to using an actual timer object (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updating to trunk Created 8 years, 10 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 CHROME_BROWSER_METRICS_METRICS_REPORTING_SCHEDULER_H_ 5 #ifndef CHROME_BROWSER_METRICS_METRICS_REPORTING_SCHEDULER_H_
6 #define CHROME_BROWSER_METRICS_METRICS_REPORTING_SCHEDULER_H_ 6 #define CHROME_BROWSER_METRICS_METRICS_REPORTING_SCHEDULER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "base/timer.h"
13 14
14 // Scheduler task to drive a MetricsService object's uploading. 15 // Scheduler task to drive a MetricsService object's uploading.
15 class MetricsReportingScheduler { 16 class MetricsReportingScheduler {
16 public: 17 public:
17 explicit MetricsReportingScheduler(const base::Closure& upload_callback); 18 explicit MetricsReportingScheduler(const base::Closure& upload_callback);
18 ~MetricsReportingScheduler(); 19 ~MetricsReportingScheduler();
19 20
20 // Starts scheduling uploads. This in a no-op if the scheduler is already 21 // 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 // running, so it is safe to call more than once.
22 void Start(); 23 void Start();
(...skipping 16 matching lines...) Expand all
39 // Schedules a future call to TriggerUpload if one isn't already pending. 40 // Schedules a future call to TriggerUpload if one isn't already pending.
40 void ScheduleNextCallback(); 41 void ScheduleNextCallback();
41 42
42 // Increases the upload interval each time it's called, to handle the case 43 // Increases the upload interval each time it's called, to handle the case
43 // where the server is having issues. 44 // where the server is having issues.
44 void BackOffUploadInterval(); 45 void BackOffUploadInterval();
45 46
46 // The MetricsService method to call when uploading should happen. 47 // The MetricsService method to call when uploading should happen.
47 base::Closure upload_callback_; 48 base::Closure upload_callback_;
48 49
49 base::WeakPtrFactory<MetricsReportingScheduler> weak_ptr_factory_; 50 base::OneShotTimer<MetricsReportingScheduler> upload_timer_;
50 51
51 // The interval between being told an upload is done and starting the next 52 // The interval between being told an upload is done and starting the next
52 // upload. 53 // upload.
53 base::TimeDelta upload_interval_; 54 base::TimeDelta upload_interval_;
54 55
55 // Indicates that the scheduler is running (i.e., that Start has been called 56 // Indicates that the scheduler is running (i.e., that Start has been called
56 // more recently than Stop). 57 // more recently than Stop).
57 bool running_; 58 bool running_;
58 59
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. 60 // Indicates that the last triggered upload hasn't resolved yet.
64 bool callback_pending_; 61 bool callback_pending_;
65 62
66 DISALLOW_COPY_AND_ASSIGN(MetricsReportingScheduler); 63 DISALLOW_COPY_AND_ASSIGN(MetricsReportingScheduler);
67 }; 64 };
68 65
69 #endif // CHROME_BROWSER_METRICS_METRICS_REPORTING_SCHEDULER_H_ 66 #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