| 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/time/time.h" | 
 |  15  | 
 |  16 namespace base { | 
 |  17 class SequencedTaskRunner; | 
 |  18 } | 
 |  19  | 
 |  20 namespace content { | 
 |  21 class BrowserContext; | 
 |  22 } | 
 |  23  | 
 |  24 namespace feedback { | 
 |  25  | 
 |  26 typedef base::Callback<void(const std::string&)> QueueCallback; | 
 |  27  | 
 |  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> { | 
 |  32  public: | 
 |  33   FeedbackReport(content::BrowserContext* context, | 
 |  34                  const base::Time& upload_at, | 
 |  35                  const std::string& data); | 
 |  36  | 
 |  37   // Stops the disk write of the report and deletes the report file if already | 
 |  38   // written. | 
 |  39   void DeleteReportOnDisk(); | 
 |  40  | 
 |  41   const base::Time& upload_at() const { return upload_at_; } | 
 |  42   const std::string& data() const { return data_; } | 
 |  43  | 
 |  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); | 
 |  48  | 
 |  49  private: | 
 |  50   friend class base::RefCounted<FeedbackReport>; | 
 |  51   virtual ~FeedbackReport(); | 
 |  52  | 
 |  53   // Name of the file corresponding to this report. | 
 |  54   base::FilePath file_; | 
 |  55  | 
 |  56   base::FilePath reports_path_; | 
 |  57   base::Time upload_at_;  // Upload this report at or after this time. | 
 |  58   std::string data_; | 
 |  59  | 
 |  60   scoped_refptr<base::SequencedTaskRunner> reports_task_runner_; | 
 |  61  | 
 |  62   DISALLOW_COPY_AND_ASSIGN(FeedbackReport); | 
 |  63 }; | 
 |  64  | 
 |  65 }  // namespace feedback | 
 |  66  | 
 |  67 #endif  // CHROME_BROWSER_FEEDBACK_FEEDBACK_REPORT_H_ | 
| OLD | NEW |