Chromium Code Reviews| Index: content/browser/loader/upload_progress_tracker.h |
| diff --git a/content/browser/loader/upload_progress_tracker.h b/content/browser/loader/upload_progress_tracker.h |
| index 4172490b35795d0a6051ace5ac8d9f3a01285435..ffe1d2a55b9da1e781c7c398f119ea26fcb02536 100644 |
| --- a/content/browser/loader/upload_progress_tracker.h |
| +++ b/content/browser/loader/upload_progress_tracker.h |
| @@ -7,48 +7,67 @@ |
| #include <stdint.h> |
| -#include "base/callback.h" |
| #include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| #include "base/time/time.h" |
| #include "base/timer/timer.h" |
| +#include "content/common/content_export.h" |
| + |
| +namespace base { |
| +class SingleThreadTaskRunner; |
| +} |
| namespace tracked_objects { |
| class Location; |
| } |
| namespace net { |
| -class URLRequest; |
| +class UploadProgress; |
| } |
| namespace content { |
| // UploadProgressTracker watches the upload progress of a URL loading, and sends |
| // the progress to the client in a suitable granularity and frequency. |
| -class UploadProgressTracker final { |
| +class CONTENT_EXPORT UploadProgressTracker final { |
| public: |
| - using UploadProgressReportCallback = |
| - base::RepeatingCallback<void(int64_t, int64_t)>; |
| - |
| - UploadProgressTracker(const tracked_objects::Location& location, |
| - UploadProgressReportCallback report_progress, |
| - net::URLRequest* request); |
| + class Client { |
| + public: |
| + virtual net::UploadProgress GetUploadProgress() = 0; |
| + virtual void ReportUploadProgress(int64_t current_position, |
| + int64_t total_size) = 0; |
| + |
| + protected: |
| + Client(); |
| + virtual ~Client(); |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(Client); |
| + }; |
| + |
| + UploadProgressTracker( |
| + const tracked_objects::Location& location, |
| + Client* client, |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| ~UploadProgressTracker(); |
| void OnAckReceived(); |
| void OnUploadCompleted(); |
| + void SetLastUploadTicksForTesting(const base::TimeTicks& ticks) { |
|
mmenke
2017/01/06 15:54:53
Think this delves too much into the underlying cod
tzik
2017/01/10 06:54:41
Done.
|
| + last_upload_ticks_ = ticks; |
| + } |
| + |
| private: |
| void ReportUploadProgressIfNeeded(); |
| - net::URLRequest* request_; // Not owned. |
| + Client* client_; // Not owned. |
| uint64_t last_upload_position_ = 0; |
| bool waiting_for_upload_progress_ack_ = false; |
| base::TimeTicks last_upload_ticks_; |
| base::RepeatingTimer progress_timer_; |
| - UploadProgressReportCallback report_progress_; |
| - |
| DISALLOW_COPY_AND_ASSIGN(UploadProgressTracker); |
| }; |