| OLD | NEW |
| 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> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // in reverse chronological order. | 88 // in reverse chronological order. |
| 89 // Must be called only after OnUploadListAvailable has been called. | 89 // Must be called only after OnUploadListAvailable has been called. |
| 90 void GetUploads(size_t max_count, std::vector<UploadInfo>* uploads); | 90 void GetUploads(size_t max_count, std::vector<UploadInfo>* uploads); |
| 91 | 91 |
| 92 protected: | 92 protected: |
| 93 virtual ~UploadList(); | 93 virtual ~UploadList(); |
| 94 | 94 |
| 95 // Reads the upload log and stores the entries in |uploads|. | 95 // Reads the upload log and stores the entries in |uploads|. |
| 96 virtual void LoadUploadList(std::vector<UploadInfo>* uploads); | 96 virtual void LoadUploadList(std::vector<UploadInfo>* uploads); |
| 97 | 97 |
| 98 const base::FilePath& upload_log_path() const; |
| 99 |
| 98 private: | 100 private: |
| 99 friend class base::RefCountedThreadSafe<UploadList>; | 101 friend class base::RefCountedThreadSafe<UploadList>; |
| 100 | 102 |
| 101 // Manages the background thread work for LoadUploadListAsynchronously(). | 103 // Manages the background thread work for LoadUploadListAsynchronously(). |
| 102 void PerformLoadAndNotifyDelegate( | 104 void PerformLoadAndNotifyDelegate( |
| 103 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | 105 const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
| 104 | 106 |
| 105 // Calls the delegate's callback method, if there is a delegate. Stores | 107 // Calls the delegate's callback method, if there is a delegate. Stores |
| 106 // the newly loaded |uploads| into |uploads_| on the delegate's task runner. | 108 // the newly loaded |uploads| into |uploads_| on the delegate's task runner. |
| 107 void SetUploadsAndNotifyDelegate(std::vector<UploadInfo> uploads); | 109 void SetUploadsAndNotifyDelegate(std::vector<UploadInfo> uploads); |
| 108 | 110 |
| 109 // Parses upload log lines, converting them to UploadInfo entries. | 111 // Parses upload log lines, converting them to UploadInfo entries. |
| 110 void ParseLogEntries(const std::vector<std::string>& log_entries, | 112 void ParseLogEntries(const std::vector<std::string>& log_entries, |
| 111 std::vector<UploadInfo>* uploads); | 113 std::vector<UploadInfo>* uploads); |
| 112 | 114 |
| 113 // |thread_checker_| ensures that |uploads_| is only set from the task runner | 115 // |thread_checker_| ensures that |uploads_| is only set from the task runner |
| 114 // that created the UploadList. | 116 // that created the UploadList. |
| 115 base::ThreadChecker thread_checker_; | 117 base::ThreadChecker thread_checker_; |
| 116 std::vector<UploadInfo> uploads_; | 118 std::vector<UploadInfo> uploads_; |
| 117 Delegate* delegate_; | 119 Delegate* delegate_; |
| 118 | 120 |
| 119 const base::FilePath upload_log_path_; | 121 const base::FilePath upload_log_path_; |
| 120 | 122 |
| 121 scoped_refptr<base::SequencedWorkerPool> worker_pool_; | 123 scoped_refptr<base::SequencedWorkerPool> worker_pool_; |
| 122 | 124 |
| 123 DISALLOW_COPY_AND_ASSIGN(UploadList); | 125 DISALLOW_COPY_AND_ASSIGN(UploadList); |
| 124 }; | 126 }; |
| 125 | 127 |
| 126 #endif // COMPONENTS_UPLOAD_LIST_UPLOAD_LIST_H_ | 128 #endif // COMPONENTS_UPLOAD_LIST_UPLOAD_LIST_H_ |
| OLD | NEW |