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

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

Issue 225183018: Move feedback files into src/components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase to latest Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_FEEDBACK_FEEDBACK_UPLOADER_H_ 5 #ifndef COMPONENTS_FEEDBACK_FEEDBACK_UPLOADER_H_
6 #define CHROME_BROWSER_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/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 17
18 namespace feedback { 18 namespace feedback {
19 19
20 typedef base::Callback<void(const std::string&)> ReportDataCallback; 20 typedef base::Callback<void(const std::string&)> ReportDataCallback;
21 21
22 class FeedbackReport; 22 class FeedbackReport;
23 23
24 // FeedbackUploader is used to add a feedback report to the queue of reports 24 // 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 25 // 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. 26 // tried again when it's turn comes up next in the queue.
27 class FeedbackUploader : public base::SupportsWeakPtr<FeedbackUploader> { 27 class FeedbackUploader : public base::SupportsWeakPtr<FeedbackUploader> {
28 public: 28 public:
29 explicit FeedbackUploader(const base::FilePath& path, 29 FeedbackUploader(const base::FilePath& path,
30 base::SequencedWorkerPool* pool); 30 base::SequencedWorkerPool* pool);
31 FeedbackUploader(const base::FilePath& path,
32 base::SequencedWorkerPool* pool,
33 const std::string& url);
31 virtual ~FeedbackUploader(); 34 virtual ~FeedbackUploader();
32 35
33 // Queues a report for uploading. 36 // Queues a report for uploading.
34 void QueueReport(const std::string& data); 37 virtual void QueueReport(const std::string& data);
35 38
36 base::FilePath GetFeedbackReportsPath() { return report_path_; } 39 base::FilePath GetFeedbackReportsPath() { return report_path_; }
37 40
41 bool QueueEmpty() const { return reports_queue_.empty(); }
42
38 protected: 43 protected:
39 friend class FeedbackUploaderTest; 44 friend class FeedbackUploaderTest;
45
40 struct ReportsUploadTimeComparator { 46 struct ReportsUploadTimeComparator {
41 bool operator()(FeedbackReport* a, FeedbackReport* b) const; 47 bool operator()(FeedbackReport* a, FeedbackReport* b) const;
42 }; 48 };
43 49
50 void Init();
51
44 // Dispatches the report to be uploaded. 52 // Dispatches the report to be uploaded.
45 virtual void DispatchReport(const std::string& data) = 0; 53 virtual void DispatchReport(const std::string& data) = 0;
46 54
47 // Update our timer for uploading the next report. 55 // Update our timer for uploading the next report.
48 void UpdateUploadTimer(); 56 void UpdateUploadTimer();
49 57
50 // Requeue this report with a delay. 58 // Requeue this report with a delay.
51 void RetryReport(const std::string& data); 59 void RetryReport(const std::string& data);
52 60
53 void QueueReportWithDelay(const std::string& data, base::TimeDelta delay); 61 void QueueReportWithDelay(const std::string& data, base::TimeDelta delay);
(...skipping 13 matching lines...) Expand all
67 ReportDataCallback dispatch_callback_; 75 ReportDataCallback dispatch_callback_;
68 base::TimeDelta retry_delay_; 76 base::TimeDelta retry_delay_;
69 std::string url_; 77 std::string url_;
70 base::SequencedWorkerPool* pool_; 78 base::SequencedWorkerPool* pool_;
71 79
72 DISALLOW_COPY_AND_ASSIGN(FeedbackUploader); 80 DISALLOW_COPY_AND_ASSIGN(FeedbackUploader);
73 }; 81 };
74 82
75 } // namespace feedback 83 } // namespace feedback
76 84
77 #endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_UPLOADER_H_ 85 #endif // COMPONENTS_FEEDBACK_FEEDBACK_UPLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698