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

Side by Side Diff: components/feedback/feedback_uploader.h

Issue 2876213002: Use TaskScheduler instead of SequencedWorkerPool in components/feedback. (Closed)
Patch Set: fix-build-errors Created 3 years, 7 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
« no previous file with comments | « components/feedback/feedback_data_unittest.cc ('k') | components/feedback/feedback_uploader.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 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_FEEDBACK_FEEDBACK_UPLOADER_H_ 5 #ifndef COMPONENTS_FEEDBACK_FEEDBACK_UPLOADER_H_
6 #define COMPONENTS_FEEDBACK_FEEDBACK_UPLOADER_H_ 6 #define COMPONENTS_FEEDBACK_FEEDBACK_UPLOADER_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 10
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/sequenced_worker_pool.h"
15 #include "base/time/time.h" 14 #include "base/time/time.h"
16 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
17 16
18 namespace feedback { 17 namespace feedback {
19 18
20 typedef base::Callback<void(const std::string&)> ReportDataCallback; 19 typedef base::Callback<void(const std::string&)> ReportDataCallback;
21 20
22 class FeedbackReport; 21 class FeedbackReport;
23 22
24 // FeedbackUploader is used to add a feedback report to the queue of reports 23 // FeedbackUploader is used to add a feedback report to the queue of reports
25 // being uploaded. In case uploading a report fails, it is written to disk and 24 // being uploaded. In case uploading a report fails, it is written to disk and
26 // tried again when it's turn comes up next in the queue. 25 // tried again when it's turn comes up next in the queue.
27 class FeedbackUploader : public base::SupportsWeakPtr<FeedbackUploader> { 26 class FeedbackUploader : public base::SupportsWeakPtr<FeedbackUploader> {
28 public: 27 public:
28 FeedbackUploader(const base::FilePath& path);
29 FeedbackUploader(const base::FilePath& path, 29 FeedbackUploader(const base::FilePath& path,
30 base::SequencedWorkerPool* pool);
31 FeedbackUploader(const base::FilePath& path,
32 base::SequencedWorkerPool* pool,
33 const std::string& url); 30 const std::string& url);
34 virtual ~FeedbackUploader(); 31 virtual ~FeedbackUploader();
35 32
36 // Queues a report for uploading. 33 // Queues a report for uploading.
37 virtual void QueueReport(const std::string& data); 34 virtual void QueueReport(const std::string& data);
38 35
39 base::FilePath GetFeedbackReportsPath() { return report_path_; } 36 base::FilePath GetFeedbackReportsPath() { return report_path_; }
40 37
41 bool QueueEmpty() const { return reports_queue_.empty(); } 38 bool QueueEmpty() const { return reports_queue_.empty(); }
42 39
(...skipping 26 matching lines...) Expand all
69 base::OneShotTimer upload_timer_; 66 base::OneShotTimer upload_timer_;
70 // Priority queue of reports prioritized by the time the report is supposed 67 // Priority queue of reports prioritized by the time the report is supposed
71 // to be uploaded at. 68 // to be uploaded at.
72 std::priority_queue<scoped_refptr<FeedbackReport>, 69 std::priority_queue<scoped_refptr<FeedbackReport>,
73 std::vector<scoped_refptr<FeedbackReport> >, 70 std::vector<scoped_refptr<FeedbackReport> >,
74 ReportsUploadTimeComparator> reports_queue_; 71 ReportsUploadTimeComparator> reports_queue_;
75 72
76 ReportDataCallback dispatch_callback_; 73 ReportDataCallback dispatch_callback_;
77 base::TimeDelta retry_delay_; 74 base::TimeDelta retry_delay_;
78 std::string url_; 75 std::string url_;
79 base::SequencedWorkerPool* pool_;
80 76
81 DISALLOW_COPY_AND_ASSIGN(FeedbackUploader); 77 DISALLOW_COPY_AND_ASSIGN(FeedbackUploader);
82 }; 78 };
83 79
84 } // namespace feedback 80 } // namespace feedback
85 81
86 #endif // COMPONENTS_FEEDBACK_FEEDBACK_UPLOADER_H_ 82 #endif // COMPONENTS_FEEDBACK_FEEDBACK_UPLOADER_H_
OLDNEW
« no previous file with comments | « components/feedback/feedback_data_unittest.cc ('k') | components/feedback/feedback_uploader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698