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

Unified Diff: content/browser/loader/upload_progress_tracker.h

Issue 2612903008: Add UploadProgressTracker unittest (Closed)
Patch Set: Created 3 years, 11 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
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);
};

Powered by Google App Engine
This is Rietveld 408576698