Chromium Code Reviews| OLD | NEW | 
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_FEEDBACK_FEEDBACK_REPORT_H_ | |
| 6 #define CHROME_BROWSER_FEEDBACK_FEEDBACK_REPORT_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 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/memory/scoped_ptr.h" | |
| 
 
Lei Zhang
2014/01/23 22:28:41
nit: not used
 
rkc
2014/01/23 22:57:21
Done.
 
 | |
| 15 #include "base/time/time.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class SequencedTaskRunner; | |
| 
 
Lei Zhang
2014/01/23 22:28:41
nit: not used
 
rkc
2014/01/23 22:57:21
Done.
 
 | |
| 19 } | |
| 20 | |
| 21 namespace content { | |
| 22 class BrowserContext; | |
| 23 } | |
| 24 | |
| 25 namespace feedback { | |
| 26 | |
| 27 typedef base::Callback<void(const std::string&)> QueueCallback; | |
| 28 | |
| 29 // This class holds a feedback report. Once a report is created, a disk backup | |
| 30 // for it is created automatically. This backup is deleted once this object | |
| 31 // dies. | |
| 32 class FeedbackReport : public base::RefCountedThreadSafe<FeedbackReport> { | |
| 33 public: | |
| 34 FeedbackReport(content::BrowserContext* context, | |
| 35 const base::Time& upload_at, | |
| 36 const std::string& data); | |
| 37 | |
| 38 // Stops the disk write of the report and deletes the report file if already | |
| 39 // written. | |
| 40 void DeleteReportOnDisk(); | |
| 41 | |
| 42 base::Time upload_at() { return upload_at_; } | |
| 43 const std::string& data() { return data_; } | |
| 44 | |
| 45 // Loads the reports still on disk and queues then using the given callback. | |
| 46 // This call blocks on the file reads. | |
| 47 static void LoadReportsAndQueue(content::BrowserContext* context, | |
| 48 QueueCallback callback); | |
| 49 | |
| 50 private: | |
| 51 friend class base::RefCountedThreadSafe<FeedbackReport>; | |
| 52 virtual ~FeedbackReport(); | |
| 53 | |
| 54 void WriteReportOnBlockingPool(); | |
| 55 | |
| 56 // Name of the file corresponding to this report. | |
| 57 base::FilePath file_; | |
| 58 | |
| 59 content::BrowserContext* context_; | |
| 60 base::Time upload_at_; // Upload this report at or after this time. | |
| 61 std::string data_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(FeedbackReport); | |
| 64 }; | |
| 65 | |
| 66 } // namespace feedback | |
| 67 | |
| 68 #endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_REPORT_H_ | |
| OLD | NEW |