| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 
|  | 2 // Use of this source code is governed by a BSD-style license that can be | 
|  | 3 // found in the LICENSE file. | 
|  | 4 | 
|  | 5 #ifndef CONTENT_BROWSER_LOADER_UPLOAD_PROGRESS_TRACKER_H_ | 
|  | 6 #define CONTENT_BROWSER_LOADER_UPLOAD_PROGRESS_TRACKER_H_ | 
|  | 7 | 
|  | 8 #include <stdint.h> | 
|  | 9 | 
|  | 10 #include "base/callback.h" | 
|  | 11 #include "base/macros.h" | 
|  | 12 #include "base/time/time.h" | 
|  | 13 #include "base/timer/timer.h" | 
|  | 14 | 
|  | 15 namespace tracked_objects { | 
|  | 16 class Location; | 
|  | 17 } | 
|  | 18 | 
|  | 19 namespace net { | 
|  | 20 class URLRequest; | 
|  | 21 } | 
|  | 22 | 
|  | 23 namespace content { | 
|  | 24 | 
|  | 25 // UploadProgressTracker watches the upload progress of a URL loading, and sends | 
|  | 26 // the progress to the client in a suitable granularity and frequency. | 
|  | 27 class UploadProgressTracker final { | 
|  | 28  public: | 
|  | 29   using UploadProgressReportCallback = | 
|  | 30       base::RepeatingCallback<void(int64_t, int64_t)>; | 
|  | 31 | 
|  | 32   UploadProgressTracker(UploadProgressReportCallback report_progress, | 
|  | 33                         net::URLRequest* request); | 
|  | 34   ~UploadProgressTracker(); | 
|  | 35 | 
|  | 36   void OnAckReceived(); | 
|  | 37 | 
|  | 38   void Start(const tracked_objects::Location& location); | 
|  | 39   void OnUploadCompleted(); | 
|  | 40 | 
|  | 41  private: | 
|  | 42   void ReportUploadProgressIfNeeded(); | 
|  | 43 | 
|  | 44   net::URLRequest* request_;  // Not owned. | 
|  | 45 | 
|  | 46   uint64_t last_upload_position_ = 0; | 
|  | 47   bool waiting_for_upload_progress_ack_ = false; | 
|  | 48   base::TimeTicks last_upload_ticks_; | 
|  | 49   base::RepeatingTimer progress_timer_; | 
|  | 50 | 
|  | 51   UploadProgressReportCallback report_progress_; | 
|  | 52 | 
|  | 53   DISALLOW_COPY_AND_ASSIGN(UploadProgressTracker); | 
|  | 54 }; | 
|  | 55 | 
|  | 56 }  // namespace content | 
|  | 57 | 
|  | 58 #endif  // CONTENT_BROWSER_LOADER_UPLOAD_PROGRESS_TRACKER_H_ | 
| OLD | NEW | 
|---|