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/synchronization/lock.h" | |
| 15 #include "base/time/time.h" | |
| 16 | |
| 17 namespace content { | |
| 18 class BrowserContext; | |
| 19 } | |
| 20 | |
| 21 namespace feedback { | |
| 22 | |
| 23 typedef base::Callback<void(const std::string&)> QueueCallback; | |
| 24 | |
| 25 // This class holds a feedback report. Once a report is created, a disk backup | |
| 26 // for it is created automatically. This backup is deleted once this object | |
| 
 
Lei Zhang
2014/02/01 01:37:22
The statement about the backup being deleted doesn
 
rkc
2014/02/03 22:13:11
Fixed.
Done.
 
 | |
| 27 // dies. | |
| 28 class FeedbackReport : public base::RefCountedThreadSafe<FeedbackReport> { | |
| 
 
Lei Zhang
2014/02/01 01:37:22
This class doesn't need to be RefCountedThreadSafe
 
rkc
2014/02/03 22:13:11
I use its ref-counted behavior to not have to mana
 
Lei Zhang
2014/02/03 22:26:51
Is there any reason you need to use refcounting to
 
rkc
2014/02/03 22:41:26
As discussed offline, changing to RefCounted versu
 
 | |
| 29 public: | |
| 30 FeedbackReport(content::BrowserContext* context, | |
| 31 const base::Time& upload_at, | |
| 32 const std::string& data); | |
| 33 | |
| 34 // Stops the disk write of the report and deletes the report file if already | |
| 35 // written. | |
| 36 void DeleteReportOnDisk(); | |
| 37 | |
| 38 base::Time upload_at() { return upload_at_; } | |
| 
 
Lei Zhang
2014/02/01 01:37:22
make the method const, return a const-ref
 
rkc
2014/02/03 22:13:11
Done.
 
 | |
| 39 const std::string& data() { return data_; } | |
| 
 
Lei Zhang
2014/02/01 01:37:22
make the method const
 
rkc
2014/02/03 22:13:11
Done.
 
 | |
| 40 | |
| 41 // Loads the reports still on disk and queues then using the given callback. | |
| 42 // This call blocks on the file reads. | |
| 43 static void LoadReportsAndQueue(content::BrowserContext* context, | |
| 44 QueueCallback callback); | |
| 45 | |
| 46 private: | |
| 47 friend class base::RefCountedThreadSafe<FeedbackReport>; | |
| 48 virtual ~FeedbackReport(); | |
| 49 | |
| 50 void WriteReportOnBlockingPool(); | |
| 51 void DeleteReportOnBlockingPool(); | |
| 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 base::Lock file_access_lock_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(FeedbackReport); | |
| 63 }; | |
| 64 | |
| 65 } // namespace feedback | |
| 66 | |
| 67 #endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_REPORT_H_ | |
| OLD | NEW |