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

Side by Side Diff: content/browser/loader/async_resource_handler.h

Issue 2546653003: Factor out upload progress handling from AsyncResourceHandler (Closed)
Patch Set: +Start, +OnUploadCompleted, -ForceReportUploadProgress Created 4 years 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 unified diff | Download patch
« no previous file with comments | « content/browser/loader/DEPS ('k') | content/browser/loader/async_resource_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ 6 #define CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
yhirano 2016/12/07 13:50:03 not needed
tzik 2016/12/08 05:57:54 Done.
15 #include "content/browser/loader/resource_handler.h" 15 #include "content/browser/loader/resource_handler.h"
16 #include "content/browser/loader/resource_message_delegate.h" 16 #include "content/browser/loader/resource_message_delegate.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "net/base/io_buffer.h" 18 #include "net/base/io_buffer.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 20
21 namespace net { 21 namespace net {
22 class URLRequest; 22 class URLRequest;
23 } 23 }
24 24
25 namespace content { 25 namespace content {
26 class ResourceBuffer; 26 class ResourceBuffer;
27 class ResourceDispatcherHostImpl; 27 class ResourceDispatcherHostImpl;
28 class UploadProgressTracker;
28 29
29 // Used to complete an asynchronous resource request in response to resource 30 // Used to complete an asynchronous resource request in response to resource
30 // load events from the resource dispatcher host. 31 // load events from the resource dispatcher host.
31 class CONTENT_EXPORT AsyncResourceHandler : public ResourceHandler, 32 class CONTENT_EXPORT AsyncResourceHandler : public ResourceHandler,
32 public ResourceMessageDelegate { 33 public ResourceMessageDelegate {
33 public: 34 public:
34 AsyncResourceHandler(net::URLRequest* request, 35 AsyncResourceHandler(net::URLRequest* request,
35 ResourceDispatcherHostImpl* rdh); 36 ResourceDispatcherHostImpl* rdh);
36 ~AsyncResourceHandler() override; 37 ~AsyncResourceHandler() override;
37 38
(...skipping 14 matching lines...) Expand all
52 void OnDataDownloaded(int bytes_downloaded) override; 53 void OnDataDownloaded(int bytes_downloaded) override;
53 54
54 private: 55 private:
55 class InliningHelper; 56 class InliningHelper;
56 57
57 // IPC message handlers: 58 // IPC message handlers:
58 void OnFollowRedirect(int request_id); 59 void OnFollowRedirect(int request_id);
59 void OnDataReceivedACK(int request_id); 60 void OnDataReceivedACK(int request_id);
60 void OnUploadProgressACK(int request_id); 61 void OnUploadProgressACK(int request_id);
61 62
62 void ReportUploadProgress();
63
64 bool EnsureResourceBufferIsInitialized(); 63 bool EnsureResourceBufferIsInitialized();
65 void ResumeIfDeferred(); 64 void ResumeIfDeferred();
66 void OnDefer(); 65 void OnDefer();
67 bool CheckForSufficientResource(); 66 bool CheckForSufficientResource();
68 int CalculateEncodedDataLengthToReport(); 67 int CalculateEncodedDataLengthToReport();
69 int CalculateEncodedBodyLengthToReport(); 68 int CalculateEncodedBodyLengthToReport();
70 void RecordHistogram(); 69 void RecordHistogram();
71 70
72 scoped_refptr<ResourceBuffer> buffer_; 71 scoped_refptr<ResourceBuffer> buffer_;
73 ResourceDispatcherHostImpl* rdh_; 72 ResourceDispatcherHostImpl* rdh_;
74 73
75 // Number of messages we've sent to the renderer that we haven't gotten an 74 // Number of messages we've sent to the renderer that we haven't gotten an
76 // ACK for. This allows us to avoid having too many messages in flight. 75 // ACK for. This allows us to avoid having too many messages in flight.
77 int pending_data_count_; 76 int pending_data_count_;
78 77
79 int allocation_size_; 78 int allocation_size_;
80 79
81 bool first_chunk_read_ = false; 80 bool first_chunk_read_ = false;
82 81
83 bool did_defer_; 82 bool did_defer_;
84 83
85 bool has_checked_for_sufficient_resources_; 84 bool has_checked_for_sufficient_resources_;
86 bool sent_received_response_msg_; 85 bool sent_received_response_msg_;
87 bool sent_data_buffer_msg_; 86 bool sent_data_buffer_msg_;
88 87
89 std::unique_ptr<InliningHelper> inlining_helper_; 88 std::unique_ptr<InliningHelper> inlining_helper_;
90 base::TimeTicks response_started_ticks_; 89 base::TimeTicks response_started_ticks_;
91 90
92 uint64_t last_upload_position_; 91 std::unique_ptr<UploadProgressTracker> upload_progress_tracker_;
93 bool waiting_for_upload_progress_ack_;
94 base::TimeTicks last_upload_ticks_;
95 base::RepeatingTimer progress_timer_;
96 92
97 int64_t reported_transfer_size_; 93 int64_t reported_transfer_size_;
98 94
99 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); 95 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler);
100 }; 96 };
101 97
102 } // namespace content 98 } // namespace content
103 99
104 #endif // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ 100 #endif // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/loader/DEPS ('k') | content/browser/loader/async_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698