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

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

Issue 1301103002: moved upload progress logic from ResourceLoader to AsyncResourceHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added license Created 5 years, 3 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 unified diff | Download patch
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 <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/timer/timer.h"
11 #include "content/browser/loader/resource_handler.h" 12 #include "content/browser/loader/resource_handler.h"
12 #include "content/browser/loader/resource_message_delegate.h" 13 #include "content/browser/loader/resource_message_delegate.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 namespace net { 16 namespace net {
16 class URLRequest; 17 class URLRequest;
17 } 18 }
18 19
19 namespace content { 20 namespace content {
20 class ResourceBuffer; 21 class ResourceBuffer;
21 class ResourceContext; 22 class ResourceContext;
22 class ResourceDispatcherHostImpl; 23 class ResourceDispatcherHostImpl;
23 class ResourceMessageFilter; 24 class ResourceMessageFilter;
24 class SharedIOBuffer; 25 class SharedIOBuffer;
25 26
26 // Used to complete an asynchronous resource request in response to resource 27 // Used to complete an asynchronous resource request in response to resource
27 // load events from the resource dispatcher host. 28 // load events from the resource dispatcher host.
28 class AsyncResourceHandler : public ResourceHandler, 29 class AsyncResourceHandler : public ResourceHandler,
29 public ResourceMessageDelegate { 30 public ResourceMessageDelegate {
30 public: 31 public:
31 AsyncResourceHandler(net::URLRequest* request, 32 AsyncResourceHandler(net::URLRequest* request,
32 ResourceDispatcherHostImpl* rdh); 33 ResourceDispatcherHostImpl* rdh);
33 ~AsyncResourceHandler() override; 34 ~AsyncResourceHandler() override;
34 35
35 bool OnMessageReceived(const IPC::Message& message) override; 36 bool OnMessageReceived(const IPC::Message& message) override;
36 37
38 void ReportUploadProgress();
mmenke 2015/08/26 19:13:12 This should be private.
39
37 // ResourceHandler implementation: 40 // ResourceHandler implementation:
38 bool OnUploadProgress(uint64 position, uint64 size) override; 41 bool OnUploadProgress(uint64 position, uint64 size);
mmenke 2015/08/26 19:13:12 This is no longer part of the ResourceHandler, and
39 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, 42 bool OnRequestRedirected(const net::RedirectInfo& redirect_info,
40 ResourceResponse* response, 43 ResourceResponse* response,
41 bool* defer) override; 44 bool* defer) override;
42 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; 45 bool OnResponseStarted(ResourceResponse* response, bool* defer) override;
43 bool OnWillStart(const GURL& url, bool* defer) override; 46 bool OnWillStart(const GURL& url, bool* defer) override;
44 bool OnBeforeNetworkStart(const GURL& url, bool* defer) override; 47 bool OnBeforeNetworkStart(const GURL& url, bool* defer) override;
45 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, 48 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf,
46 int* buf_size, 49 int* buf_size,
47 int min_size) override; 50 int min_size) override;
48 bool OnReadCompleted(int bytes_read, bool* defer) override; 51 bool OnReadCompleted(int bytes_read, bool* defer) override;
49 void OnResponseCompleted(const net::URLRequestStatus& status, 52 void OnResponseCompleted(const net::URLRequestStatus& status,
50 const std::string& security_info, 53 const std::string& security_info,
51 bool* defer) override; 54 bool* defer) override;
52 void OnDataDownloaded(int bytes_downloaded) override; 55 void OnDataDownloaded(int bytes_downloaded) override;
53 56
54 private: 57 private:
55 // IPC message handlers: 58 // IPC message handlers:
56 void OnFollowRedirect(int request_id); 59 void OnFollowRedirect(int request_id);
60 void OnUploadProgressACK(int request_id);
57 void OnDataReceivedACK(int request_id); 61 void OnDataReceivedACK(int request_id);
58 62
59 bool EnsureResourceBufferIsInitialized(); 63 bool EnsureResourceBufferIsInitialized();
60 void ResumeIfDeferred(); 64 void ResumeIfDeferred();
61 void OnDefer(); 65 void OnDefer();
62 66
63 scoped_refptr<ResourceBuffer> buffer_; 67 scoped_refptr<ResourceBuffer> buffer_;
64 ResourceDispatcherHostImpl* rdh_; 68 ResourceDispatcherHostImpl* rdh_;
65 69
66 // Number of messages we've sent to the renderer that we haven't gotten an 70 // Number of messages we've sent to the renderer that we haven't gotten an
67 // ACK for. This allows us to avoid having too many messages in flight. 71 // ACK for. This allows us to avoid having too many messages in flight.
68 int pending_data_count_; 72 int pending_data_count_;
69 73
70 int allocation_size_; 74 int allocation_size_;
71 75
72 bool did_defer_; 76 bool did_defer_;
73 77
74 bool has_checked_for_sufficient_resources_; 78 bool has_checked_for_sufficient_resources_;
75 bool sent_received_response_msg_; 79 bool sent_received_response_msg_;
76 bool sent_first_data_msg_; 80 bool sent_first_data_msg_;
77 81
82 uint64 last_upload_position_;
83 bool waiting_for_upload_progress_ack_;
84 base::TimeTicks last_upload_ticks_;
85 base::RepeatingTimer<AsyncResourceHandler> progress_timer_;
86
78 int64_t reported_transfer_size_; 87 int64_t reported_transfer_size_;
79 88
80 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); 89 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler);
81 }; 90 };
82 91
83 } // namespace content 92 } // namespace content
84 93
85 #endif // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ 94 #endif // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698