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

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

Issue 2612903008: Add UploadProgressTracker unittest (Closed)
Patch Set: +expectation for unreported small progress. 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
« no previous file with comments | « content/browser/loader/async_resource_handler.cc ('k') | content/browser/loader/upload_progress_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6840f5a60bc174c5a01e547df2539b9878a74970 100644
--- a/content/browser/loader/upload_progress_tracker.h
+++ b/content/browser/loader/upload_progress_tracker.h
@@ -9,8 +9,17 @@
#include "base/callback.h"
#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/single_thread_task_runner.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
+#include "content/common/content_export.h"
+#include "net/base/upload_progress.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+}
namespace tracked_objects {
class Location;
@@ -24,20 +33,26 @@ 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 {
public:
using UploadProgressReportCallback =
- base::RepeatingCallback<void(int64_t, int64_t)>;
+ base::RepeatingCallback<void(const net::UploadProgress&)>;
UploadProgressTracker(const tracked_objects::Location& location,
UploadProgressReportCallback report_progress,
- net::URLRequest* request);
+ net::URLRequest* request,
+ scoped_refptr<base::SingleThreadTaskRunner>
+ task_runner = base::ThreadTaskRunnerHandle::Get());
~UploadProgressTracker();
void OnAckReceived();
void OnUploadCompleted();
private:
+ // Overridden by tests to use a fake time and progress.
+ virtual base::TimeTicks GetCurrentTime() const;
+ virtual net::UploadProgress GetUploadProgress() const;
+
void ReportUploadProgressIfNeeded();
net::URLRequest* request_; // Not owned.
« no previous file with comments | « content/browser/loader/async_resource_handler.cc ('k') | content/browser/loader/upload_progress_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698