Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: components/upload_list/upload_list.h

Issue 1405373002: Fix WebRTC log list errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/crash/core/browser/crashes_ui_util.cc ('k') | components/upload_list/upload_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_UPLOAD_LIST_UPLOAD_LIST_H_ 5 #ifndef COMPONENTS_UPLOAD_LIST_UPLOAD_LIST_H_
6 #define COMPONENTS_UPLOAD_LIST_UPLOAD_LIST_H_ 6 #define COMPONENTS_UPLOAD_LIST_UPLOAD_LIST_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 16
17 namespace base { 17 namespace base {
18 class SequencedTaskRunner; 18 class SequencedTaskRunner;
19 class SequencedWorkerPool; 19 class SequencedWorkerPool;
20 } 20 }
21 21
22 // Loads and parses an upload list text file of the format 22 // Loads and parses an upload list text file of the format
23 // time,id[,local_id] 23 // upload_time,upload_id[,local_id[,capture_time]]
24 // time,id[,local_id] 24 // upload_time,upload_id[,local_id[,capture_time]]
25 // etc. 25 // etc.
26 // where each line represents an upload and "time" is Unix time. Must be used 26 // where each line represents an upload. |upload_time| and |capture_time| are
27 // from the UI thread. The loading and parsing is done on a blocking pool task 27 // in Unix time. Must be used from the UI thread. The loading and parsing is
28 // runner. A line may or may not contain "local_id". 28 // done on a blocking pool task runner. A line may or may not contain
29 // |local_id| and |capture_time|.
29 class UploadList : public base::RefCountedThreadSafe<UploadList> { 30 class UploadList : public base::RefCountedThreadSafe<UploadList> {
30 public: 31 public:
31 struct UploadInfo { 32 struct UploadInfo {
32 UploadInfo(const std::string& id, 33 UploadInfo(const std::string& upload_id,
33 const base::Time& t, 34 const base::Time& upload_time,
34 const std::string& local_id); 35 const std::string& local_id,
35 UploadInfo(const std::string& id, const base::Time& t); 36 const base::Time& capture_time);
37 UploadInfo(const std::string& upload_id, const base::Time& upload_time);
36 ~UploadInfo(); 38 ~UploadInfo();
37 39
38 std::string id; 40 std::string upload_id;
39 base::Time time; 41 base::Time upload_time;
40 // ID for a locally stored object that may or may not be uploaded. 42
43 // ID for locally stored data that may or may not be uploaded.
41 std::string local_id; 44 std::string local_id;
45
46 // The time the data was captured. This is useful if the data is stored
47 // locally when captured and uploaded at a later time.
48 base::Time capture_time;
42 }; 49 };
43 50
44 class Delegate { 51 class Delegate {
45 public: 52 public:
46 // Invoked when the upload list has been loaded. Will be called on the 53 // Invoked when the upload list has been loaded. Will be called on the
47 // UI thread. 54 // UI thread.
48 virtual void OnUploadListAvailable() = 0; 55 virtual void OnUploadListAvailable() = 0;
49 56
50 protected: 57 protected:
51 virtual ~Delegate() {} 58 virtual ~Delegate() {}
(...skipping 24 matching lines...) Expand all
76 virtual void LoadUploadList(); 83 virtual void LoadUploadList();
77 84
78 // Adds |info| to |uploads_|. 85 // Adds |info| to |uploads_|.
79 void AppendUploadInfo(const UploadInfo& info); 86 void AppendUploadInfo(const UploadInfo& info);
80 87
81 // Clear |uploads_|. 88 // Clear |uploads_|.
82 void ClearUploads(); 89 void ClearUploads();
83 90
84 private: 91 private:
85 friend class base::RefCountedThreadSafe<UploadList>; 92 friend class base::RefCountedThreadSafe<UploadList>;
86 FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseLogEntries); 93 FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseUploadTimeUploadId);
87 FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseLogEntriesWithLocalId); 94 FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseUploadTimeUploadIdLocalId);
95 FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseUploadTimeUploadIdCaptureTime);
96 FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseLocalIdCaptureTime);
97 FRIEND_TEST_ALL_PREFIXES(UploadListTest,
98 ParseUploadTimeUploadIdLocalIdCaptureTime);
99 FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseMultipleEntries);
88 100
89 // Manages the background thread work for LoadUploadListAsynchronously(). 101 // Manages the background thread work for LoadUploadListAsynchronously().
90 void LoadUploadListAndInformDelegateOfCompletion( 102 void LoadUploadListAndInformDelegateOfCompletion(
91 const scoped_refptr<base::SequencedTaskRunner>& task_runner); 103 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
92 104
93 // Calls the delegate's callback method, if there is a delegate. 105 // Calls the delegate's callback method, if there is a delegate.
94 void InformDelegateOfCompletion(); 106 void InformDelegateOfCompletion();
95 107
96 // Parses upload log lines, converting them to UploadInfo entries. 108 // Parses upload log lines, converting them to UploadInfo entries.
97 void ParseLogEntries(const std::vector<std::string>& log_entries); 109 void ParseLogEntries(const std::vector<std::string>& log_entries);
98 110
99 std::vector<UploadInfo> uploads_; 111 std::vector<UploadInfo> uploads_;
100 Delegate* delegate_; 112 Delegate* delegate_;
101 const base::FilePath upload_log_path_; 113 const base::FilePath upload_log_path_;
102 114
103 base::ThreadChecker thread_checker_; 115 base::ThreadChecker thread_checker_;
104 scoped_refptr<base::SequencedWorkerPool> worker_pool_; 116 scoped_refptr<base::SequencedWorkerPool> worker_pool_;
105 117
106 DISALLOW_COPY_AND_ASSIGN(UploadList); 118 DISALLOW_COPY_AND_ASSIGN(UploadList);
107 }; 119 };
108 120
109 #endif // COMPONENTS_UPLOAD_LIST_UPLOAD_LIST_H_ 121 #endif // COMPONENTS_UPLOAD_LIST_UPLOAD_LIST_H_
OLDNEW
« no previous file with comments | « components/crash/core/browser/crashes_ui_util.cc ('k') | components/upload_list/upload_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698