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

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

Issue 2335193007: Remove explicit usage of SequencedWorkerPool from UploadList. (Closed)
Patch Set: rebase on r417159 Created 4 years, 3 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/upload_list/crash_upload_list.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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/threading/thread_checker.h" 16 #include "base/sequence_checker.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 18
19 namespace base { 19 namespace base {
20 class SequencedTaskRunner; 20 class SequencedTaskRunner;
21 class SequencedWorkerPool; 21 class TaskRunner;
22 } 22 }
23 23
24 // Loads and parses an upload list text file of the format 24 // Loads and parses an upload list text file of the format
25 // upload_time,upload_id[,local_id[,capture_time[,state]]] 25 // upload_time,upload_id[,local_id[,capture_time[,state]]]
26 // upload_time,upload_id[,local_id[,capture_time[,state]]] 26 // upload_time,upload_id[,local_id[,capture_time[,state]]]
27 // etc. 27 // etc.
28 // where each line represents an upload. |upload_time| and |capture_time| are in 28 // where each line represents an upload. |upload_time| and |capture_time| are in
29 // Unix time. |state| is an int in the range of UploadInfo::State. Must be used 29 // Unix time. |state| is an int in the range of UploadInfo::State. Must be used
30 // from the UI thread. The loading and parsing is done on a blocking pool task 30 // from the UI thread. The loading and parsing is done on a blocking pool task
31 // runner. A line may or may not contain |local_id|, |capture_time|, and 31 // runner. A line may or may not contain |local_id|, |capture_time|, and
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // UI thread. 77 // UI thread.
78 virtual void OnUploadListAvailable() = 0; 78 virtual void OnUploadListAvailable() = 0;
79 79
80 protected: 80 protected:
81 virtual ~Delegate() {} 81 virtual ~Delegate() {}
82 }; 82 };
83 83
84 // Creates a new upload list with the given callback delegate. 84 // Creates a new upload list with the given callback delegate.
85 UploadList(Delegate* delegate, 85 UploadList(Delegate* delegate,
86 const base::FilePath& upload_log_path, 86 const base::FilePath& upload_log_path,
87 const scoped_refptr<base::SequencedWorkerPool>& worker_pool); 87 scoped_refptr<base::TaskRunner> task_runner);
88 88
89 // Starts loading the upload list. OnUploadListAvailable will be called when 89 // Starts loading the upload list. OnUploadListAvailable will be called when
90 // loading is complete. 90 // loading is complete.
91 void LoadUploadListAsynchronously(); 91 void LoadUploadListAsynchronously();
92 92
93 // Asynchronously requests a user triggered upload. 93 // Asynchronously requests a user triggered upload.
94 void RequestSingleCrashUploadAsync(const std::string& local_id); 94 void RequestSingleCrashUploadAsync(const std::string& local_id);
95 95
96 // Clears the delegate, so that any outstanding asynchronous load will not 96 // Clears the delegate, so that any outstanding asynchronous load will not
97 // call the delegate on completion. 97 // call the delegate on completion.
(...skipping 13 matching lines...) Expand all
111 // Requests a user triggered upload for a crash report with a given id. 111 // Requests a user triggered upload for a crash report with a given id.
112 virtual void RequestSingleCrashUpload(const std::string& local_id); 112 virtual void RequestSingleCrashUpload(const std::string& local_id);
113 113
114 const base::FilePath& upload_log_path() const; 114 const base::FilePath& upload_log_path() const;
115 115
116 private: 116 private:
117 friend class base::RefCountedThreadSafe<UploadList>; 117 friend class base::RefCountedThreadSafe<UploadList>;
118 118
119 // Manages the background thread work for LoadUploadListAsynchronously(). 119 // Manages the background thread work for LoadUploadListAsynchronously().
120 void PerformLoadAndNotifyDelegate( 120 void PerformLoadAndNotifyDelegate(
121 const scoped_refptr<base::SequencedTaskRunner>& task_runner); 121 scoped_refptr<base::SequencedTaskRunner> task_runner);
122 122
123 // Calls the delegate's callback method, if there is a delegate. Stores 123 // Calls the delegate's callback method, if there is a delegate. Stores
124 // the newly loaded |uploads| into |uploads_| on the delegate's task runner. 124 // the newly loaded |uploads| into |uploads_| on the delegate's task runner.
125 void SetUploadsAndNotifyDelegate(std::vector<UploadInfo> uploads); 125 void SetUploadsAndNotifyDelegate(std::vector<UploadInfo> uploads);
126 126
127 // Parses upload log lines, converting them to UploadInfo entries. 127 // Parses upload log lines, converting them to UploadInfo entries.
128 void ParseLogEntries(const std::vector<std::string>& log_entries, 128 void ParseLogEntries(const std::vector<std::string>& log_entries,
129 std::vector<UploadInfo>* uploads); 129 std::vector<UploadInfo>* uploads);
130 130
131 // |thread_checker_| ensures that |uploads_| is only set from the task runner 131 // Ensures that this class' thread unsafe state is only accessed from the
132 // that created the UploadList. 132 // sequence that owns this UploadList.
133 base::ThreadChecker thread_checker_; 133 base::SequenceChecker sequence_checker_;
134
134 std::vector<UploadInfo> uploads_; 135 std::vector<UploadInfo> uploads_;
136
135 Delegate* delegate_; 137 Delegate* delegate_;
136 138
137 const base::FilePath upload_log_path_; 139 const base::FilePath upload_log_path_;
138 140
139 scoped_refptr<base::SequencedWorkerPool> worker_pool_; 141 const scoped_refptr<base::TaskRunner> task_runner_;
140 142
141 DISALLOW_COPY_AND_ASSIGN(UploadList); 143 DISALLOW_COPY_AND_ASSIGN(UploadList);
142 }; 144 };
143 145
144 #endif // COMPONENTS_UPLOAD_LIST_UPLOAD_LIST_H_ 146 #endif // COMPONENTS_UPLOAD_LIST_UPLOAD_LIST_H_
OLDNEW
« no previous file with comments | « components/upload_list/crash_upload_list.cc ('k') | components/upload_list/upload_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698