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