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

Unified Diff: components/upload_list/upload_list.h

Issue 1830383002: Fix thread safety issues with //components/upload_list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/upload_list/BUILD.gn ('k') | components/upload_list/upload_list.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/upload_list/upload_list.h
diff --git a/components/upload_list/upload_list.h b/components/upload_list/upload_list.h
index 0a237a4f7c0bda34e8ede8c1a2bb7d1bc77d1b01..2bc3fe7affc19807111b872740c26b4182929f1e 100644
--- a/components/upload_list/upload_list.h
+++ b/components/upload_list/upload_list.h
@@ -5,11 +5,12 @@
#ifndef COMPONENTS_UPLOAD_LIST_UPLOAD_LIST_H_
#define COMPONENTS_UPLOAD_LIST_UPLOAD_LIST_H_
+#include <stddef.h>
+
#include <string>
#include <vector>
#include "base/files/file_path.h"
-#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/threading/thread_checker.h"
@@ -75,45 +76,37 @@ class UploadList : public base::RefCountedThreadSafe<UploadList> {
// Populates |uploads| with the |max_count| most recent uploads,
// in reverse chronological order.
// Must be called only after OnUploadListAvailable has been called.
- void GetUploads(unsigned int max_count, std::vector<UploadInfo>* uploads);
+ void GetUploads(size_t max_count, std::vector<UploadInfo>* uploads);
protected:
virtual ~UploadList();
- // Reads the upload log and stores the entries in |uploads_|.
- virtual void LoadUploadList();
-
- // Adds |info| to |uploads_|.
- void AppendUploadInfo(const UploadInfo& info);
-
- // Clear |uploads_|.
- void ClearUploads();
+ // Reads the upload log and stores the entries in |uploads|.
+ virtual void LoadUploadList(std::vector<UploadInfo>* uploads);
private:
friend class base::RefCountedThreadSafe<UploadList>;
- FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseUploadTimeUploadId);
- FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseUploadTimeUploadIdLocalId);
- FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseUploadTimeUploadIdCaptureTime);
- FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseLocalIdCaptureTime);
- FRIEND_TEST_ALL_PREFIXES(UploadListTest,
- ParseUploadTimeUploadIdLocalIdCaptureTime);
- FRIEND_TEST_ALL_PREFIXES(UploadListTest, ParseMultipleEntries);
// Manages the background thread work for LoadUploadListAsynchronously().
- void LoadUploadListAndInformDelegateOfCompletion(
+ void PerformLoadAndNotifyDelegate(
const scoped_refptr<base::SequencedTaskRunner>& task_runner);
- // Calls the delegate's callback method, if there is a delegate.
- void InformDelegateOfCompletion();
+ // Calls the delegate's callback method, if there is a delegate. Stores
+ // the newly loaded |uploads| into |uploads_| on the delegate's task runner.
+ void SetUploadsAndNotifyDelegate(std::vector<UploadInfo> uploads);
// Parses upload log lines, converting them to UploadInfo entries.
- void ParseLogEntries(const std::vector<std::string>& log_entries);
+ void ParseLogEntries(const std::vector<std::string>& log_entries,
+ std::vector<UploadInfo>* uploads);
+ // |thread_checker_| ensures that |uploads_| is only set from the task runner
+ // that created the UploadList.
+ base::ThreadChecker thread_checker_;
std::vector<UploadInfo> uploads_;
Delegate* delegate_;
+
const base::FilePath upload_log_path_;
- base::ThreadChecker thread_checker_;
scoped_refptr<base::SequencedWorkerPool> worker_pool_;
DISALLOW_COPY_AND_ASSIGN(UploadList);
« no previous file with comments | « components/upload_list/BUILD.gn ('k') | components/upload_list/upload_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698