diff options
Diffstat (limited to 'chrome/browser/feedback/feedback_uploader.h')
-rw-r--r-- | chrome/browser/feedback/feedback_uploader.h | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/chrome/browser/feedback/feedback_uploader.h b/chrome/browser/feedback/feedback_uploader.h index 415b16d..2bef774 100644 --- a/chrome/browser/feedback/feedback_uploader.h +++ b/chrome/browser/feedback/feedback_uploader.h @@ -9,41 +9,40 @@ #include <string> #include "base/basictypes.h" +#include "base/file_util.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "base/timer/timer.h" -#include "chrome/browser/feedback/feedback_uploader_delegate.h" -#include "components/keyed_service/core/keyed_service.h" - -namespace content { -class BrowserContext; -} namespace feedback { +typedef base::Callback<void(const std::string&)> ReportDataCallback; + class FeedbackReport; // FeedbackUploader is used to add a feedback report to the queue of reports // being uploaded. In case uploading a report fails, it is written to disk and // tried again when it's turn comes up next in the queue. -class FeedbackUploader : public KeyedService, - public base::SupportsWeakPtr<FeedbackUploader> { +class FeedbackUploader : public base::SupportsWeakPtr<FeedbackUploader> { public: - explicit FeedbackUploader(content::BrowserContext* context); + explicit FeedbackUploader(const base::FilePath& path, + base::SequencedWorkerPool* pool); virtual ~FeedbackUploader(); // Queues a report for uploading. void QueueReport(const std::string& data); - private: + base::FilePath GetFeedbackReportsPath() { return report_path_; } + + protected: friend class FeedbackUploaderTest; struct ReportsUploadTimeComparator { bool operator()(FeedbackReport* a, FeedbackReport* b) const; }; // Dispatches the report to be uploaded. - void DispatchReport(const std::string& data); + virtual void DispatchReport(const std::string& data) = 0; // Update our timer for uploading the next report. void UpdateUploadTimer(); @@ -51,11 +50,12 @@ class FeedbackUploader : public KeyedService, // Requeue this report with a delay. void RetryReport(const std::string& data); + void QueueReportWithDelay(const std::string& data, base::TimeDelta delay); + void setup_for_test(const ReportDataCallback& dispatch_callback, const base::TimeDelta& retry_delay); - // Browser context this uploader was created for. - content::BrowserContext* context_; + base::FilePath report_path_; // Timer to upload the next report at. base::OneShotTimer<FeedbackUploader> upload_timer_; // Priority queue of reports prioritized by the time the report is supposed @@ -66,6 +66,8 @@ class FeedbackUploader : public KeyedService, ReportDataCallback dispatch_callback_; base::TimeDelta retry_delay_; + std::string url_; + base::SequencedWorkerPool* pool_; DISALLOW_COPY_AND_ASSIGN(FeedbackUploader); }; |