#ifndef CHROME_BROWSER_UPLOAD_LIST_H_
#define CHROME_BROWSER_UPLOAD_LIST_H_
#include <string>
#include <vector>
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/time/time.h"
class UploadList : public base::RefCountedThreadSafe<UploadList> {
public:
struct UploadInfo {
UploadInfo(const std::string& id,
const base::Time& t,
const std::string& local_id);
UploadInfo(const std::string& id, const base::Time& t);
~UploadInfo();
std::string id;
base::Time time;
std::string local_id;
};
class Delegate {
public:
virtual void OnUploadListAvailable() = 0;
protected:
virtual ~Delegate() {}
};
UploadList(Delegate* delegate, const base::FilePath& upload_log_path);
void LoadUploadListAsynchronously();
void ClearDelegate();
void GetUploads(unsigned int max_count, std::vector<UploadInfo>* uploads);
protected:
virtual ~UploadList();
virtual void LoadUploadList();
void AppendUploadInfo(const UploadInfo& info);
void ClearUploads();
private:
friend class base::RefCountedThreadSafe<UploadList>;
FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseLogEntries);
FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseLogEntriesWithLocalId);
void LoadUploadListAndInformDelegateOfCompletion();
void InformDelegateOfCompletion();
void ParseLogEntries(const std::vector<std::string>& log_entries);
std::vector<UploadInfo> uploads_;
Delegate* delegate_;
const base::FilePath upload_log_path_;
DISALLOW_COPY_AND_ASSIGN(UploadList);
};
#endif