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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_FEEDBACK_FEEDBACK_REPORT_H_
6 #define CHROME_BROWSER_FEEDBACK_FEEDBACK_REPORT_H_
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/time/time.h"
17 class SequencedTaskRunner
;
26 typedef base::Callback
<void(const std::string
&)> QueueCallback
;
28 // This class holds a feedback report. Once a report is created, a disk backup
29 // for it is created automatically. This backup needs to explicitly be
30 // deleted by calling DeleteReportOnDisk.
31 class FeedbackReport
: public base::RefCounted
<FeedbackReport
> {
33 FeedbackReport(content::BrowserContext
* context
,
34 const base::Time
& upload_at
,
35 const std::string
& data
);
37 // Stops the disk write of the report and deletes the report file if already
39 void DeleteReportOnDisk();
41 const base::Time
& upload_at() const { return upload_at_
; }
42 const std::string
& data() const { return data_
; }
44 // Loads the reports still on disk and queues then using the given callback.
45 // This call blocks on the file reads.
46 static void LoadReportsAndQueue(content::BrowserContext
* context
,
47 QueueCallback callback
);
50 friend class base::RefCounted
<FeedbackReport
>;
51 virtual ~FeedbackReport();
53 // Name of the file corresponding to this report.
56 base::FilePath reports_path_
;
57 base::Time upload_at_
; // Upload this report at or after this time.
60 scoped_refptr
<base::SequencedTaskRunner
> reports_task_runner_
;
62 DISALLOW_COPY_AND_ASSIGN(FeedbackReport
);
65 } // namespace feedback
67 #endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_REPORT_H_