Chromium Code Reviews| Index: chrome/browser/feedback/feedback_report.h |
| diff --git a/chrome/browser/feedback/feedback_report.h b/chrome/browser/feedback/feedback_report.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b918b109f08ac31ce643e19278b2810b86e4e42a |
| --- /dev/null |
| +++ b/chrome/browser/feedback/feedback_report.h |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_FEEDBACK_FEEDBACK_REPORT_H_ |
| +#define CHROME_BROWSER_FEEDBACK_FEEDBACK_REPORT_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/callback_forward.h" |
| +#include "base/files/file_path.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/synchronization/lock.h" |
| +#include "base/time/time.h" |
| + |
| +namespace content { |
| +class BrowserContext; |
| +} |
| + |
| +namespace feedback { |
| + |
| +typedef base::Callback<void(const std::string&)> QueueCallback; |
| + |
| +// This class holds a feedback report. Once a report is created, a disk backup |
| +// 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.
|
| +// dies. |
| +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
|
| + public: |
| + FeedbackReport(content::BrowserContext* context, |
| + const base::Time& upload_at, |
| + const std::string& data); |
| + |
| + // Stops the disk write of the report and deletes the report file if already |
| + // written. |
| + void DeleteReportOnDisk(); |
| + |
| + 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.
|
| + 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.
|
| + |
| + // Loads the reports still on disk and queues then using the given callback. |
| + // This call blocks on the file reads. |
| + static void LoadReportsAndQueue(content::BrowserContext* context, |
| + QueueCallback callback); |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<FeedbackReport>; |
| + virtual ~FeedbackReport(); |
| + |
| + void WriteReportOnBlockingPool(); |
| + void DeleteReportOnBlockingPool(); |
| + |
| + // Name of the file corresponding to this report. |
| + base::FilePath file_; |
| + |
| + base::FilePath reports_path_; |
| + base::Time upload_at_; // Upload this report at or after this time. |
| + std::string data_; |
| + |
| + base::Lock file_access_lock_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FeedbackReport); |
| +}; |
| + |
| +} // namespace feedback |
| + |
| +#endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_REPORT_H_ |