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

Side by Side Diff: chrome/browser/feedback/feedback_uploader.h

Issue 133193004: Revert of Cache feedback reports to disk in case of send failure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
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 CHROME_BROWSER_FEEDBACK_FEEDBACK_UPLOADER_H_
6 #define CHROME_BROWSER_FEEDBACK_FEEDBACK_UPLOADER_H_ 6 #define CHROME_BROWSER_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/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 #include "chrome/browser/feedback/feedback_uploader_delegate.h" 16 #include "chrome/browser/feedback/feedback_uploader_delegate.h"
17 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 17 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
18 18
19 namespace content { 19 namespace content {
20 class BrowserContext; 20 class BrowserContext;
21 } 21 }
22 22
23 namespace feedback { 23 namespace feedback {
24 24
25 class FeedbackReport; 25 struct FeedbackReport;
26 26
27 // FeedbackUploader is used to add a feedback report to the queue of reports 27 // FeedbackUploader is used to add a feedback report to the queue of reports
28 // being uploaded. In case uploading a report fails, it is written to disk and 28 // being uploaded. In case uploading a report fails, it is written to disk and
29 // tried again when it's turn comes up next in the queue. 29 // tried again when it's turn comes up next in the queue.
30 class FeedbackUploader : public BrowserContextKeyedService, 30 class FeedbackUploader : public BrowserContextKeyedService,
31 public base::SupportsWeakPtr<FeedbackUploader> { 31 public base::SupportsWeakPtr<FeedbackUploader> {
32 public: 32 public:
33 explicit FeedbackUploader(content::BrowserContext* context); 33 explicit FeedbackUploader(content::BrowserContext* context);
34 virtual ~FeedbackUploader(); 34 virtual ~FeedbackUploader();
35 35
36 // Queues a report for uploading. 36 void QueueReport(scoped_ptr<std::string> data);
37 void QueueReport(const std::string& data);
38 37
39 private: 38 private:
40 friend class FeedbackUploaderTest; 39 friend class FeedbackUploaderTest;
41 struct ReportsUploadTimeComparator { 40 struct ReportsUploadTimeComparator {
42 bool operator()(FeedbackReport* a, FeedbackReport* b) const; 41 bool operator()(const FeedbackReport& a, const FeedbackReport& b) const;
43 }; 42 };
44 43
45 // Dispatches the report to be uploaded. 44 // Dispatches the report to be uploaded.
46 void DispatchReport(const std::string& data); 45 void DispatchReport(scoped_ptr<std::string> data);
47
48 // Loads any unsent reports from disk and queues them to be uploaded in
49 // the given browser context.
50 void QueueUnsentReports(content::BrowserContext* context);
51 46
52 // Update our timer for uploading the next report. 47 // Update our timer for uploading the next report.
53 void UpdateUploadTimer(); 48 void UpdateUploadTimer();
54 49
55 // Requeue this report with a delay. 50 // Requeue this report with a delay.
56 void RetryReport(const std::string& data); 51 void RetryReport(scoped_ptr<std::string> data);
57 52
58 void setup_for_test(const ReportDataCallback& dispatch_callback, 53 void setup_for_test(const ReportDataCallback& dispatch_callback,
59 const base::TimeDelta& retry_delay); 54 const base::TimeDelta& retry_delay);
60 55
61 // Browser context this uploader was created for. 56 // Browser context this uploader was created for.
62 content::BrowserContext* context_; 57 content::BrowserContext* context_;
63 // Timer to upload the next report at. 58 // Timer to upload the next report at.
64 base::OneShotTimer<FeedbackUploader> upload_timer_; 59 base::OneShotTimer<FeedbackUploader> upload_timer_;
65 // Priority queue of reports prioritized by the time the report is supposed 60 // Priority queue of reports prioritized by the time the report is supposed
66 // to be uploaded at. 61 // to be uploaded at.
67 std::priority_queue<scoped_refptr<FeedbackReport>, 62 std::priority_queue<FeedbackReport,
68 std::vector<scoped_refptr<FeedbackReport> >, 63 std::vector<FeedbackReport>,
69 ReportsUploadTimeComparator> reports_queue_; 64 ReportsUploadTimeComparator> reports_queue_;
70 65
66 std::vector<FeedbackReport> loaded_reports_;
67
71 ReportDataCallback dispatch_callback_; 68 ReportDataCallback dispatch_callback_;
72 base::TimeDelta retry_delay_; 69 base::TimeDelta retry_delay_;
73 70
74 DISALLOW_COPY_AND_ASSIGN(FeedbackUploader); 71 DISALLOW_COPY_AND_ASSIGN(FeedbackUploader);
75 }; 72 };
76 73
77 } // namespace feedback 74 } // namespace feedback
78 75
79 #endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_UPLOADER_H_ 76 #endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_UPLOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/feedback/feedback_report.cc ('k') | chrome/browser/feedback/feedback_uploader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698