OLD | NEW |
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 <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
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 ResourceController; |
27 class ResourceDispatcherHostImpl; | 28 class ResourceDispatcherHostImpl; |
28 class UploadProgressTracker; | 29 class UploadProgressTracker; |
29 | 30 |
30 // Used to complete an asynchronous resource request in response to resource | 31 // Used to complete an asynchronous resource request in response to resource |
31 // load events from the resource dispatcher host. | 32 // load events from the resource dispatcher host. |
32 class CONTENT_EXPORT AsyncResourceHandler : public ResourceHandler, | 33 class CONTENT_EXPORT AsyncResourceHandler : public ResourceHandler, |
33 public ResourceMessageDelegate { | 34 public ResourceMessageDelegate { |
34 public: | 35 public: |
35 AsyncResourceHandler(net::URLRequest* request, | 36 AsyncResourceHandler(net::URLRequest* request, |
36 ResourceDispatcherHostImpl* rdh); | 37 ResourceDispatcherHostImpl* rdh); |
37 ~AsyncResourceHandler() override; | 38 ~AsyncResourceHandler() override; |
38 | 39 |
39 bool OnMessageReceived(const IPC::Message& message) override; | 40 bool OnMessageReceived(const IPC::Message& message) override; |
40 | 41 |
41 // ResourceHandler implementation: | 42 // ResourceHandler implementation: |
42 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, | 43 void OnRequestRedirected( |
43 ResourceResponse* response, | 44 const net::RedirectInfo& redirect_info, |
44 bool* defer) override; | 45 ResourceResponse* response, |
45 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; | 46 std::unique_ptr<ResourceController> controller) override; |
46 bool OnWillStart(const GURL& url, bool* defer) override; | 47 void OnResponseStarted( |
| 48 ResourceResponse* response, |
| 49 std::unique_ptr<ResourceController> controller) override; |
| 50 void OnWillStart(const GURL& url, |
| 51 std::unique_ptr<ResourceController> controller) override; |
47 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 52 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
48 int* buf_size, | 53 int* buf_size, |
49 int min_size) override; | 54 int min_size) override; |
50 bool OnReadCompleted(int bytes_read, bool* defer) override; | 55 void OnReadCompleted(int bytes_read, |
51 void OnResponseCompleted(const net::URLRequestStatus& status, | 56 std::unique_ptr<ResourceController> controller) override; |
52 bool* defer) override; | 57 void OnResponseCompleted( |
| 58 const net::URLRequestStatus& status, |
| 59 std::unique_ptr<ResourceController> controller) override; |
53 void OnDataDownloaded(int bytes_downloaded) override; | 60 void OnDataDownloaded(int bytes_downloaded) override; |
54 | 61 |
55 private: | 62 private: |
56 class InliningHelper; | 63 class InliningHelper; |
57 | 64 |
58 // IPC message handlers: | 65 // IPC message handlers: |
59 void OnFollowRedirect(int request_id); | 66 void OnFollowRedirect(int request_id); |
60 void OnDataReceivedACK(int request_id); | 67 void OnDataReceivedACK(int request_id); |
61 void OnUploadProgressACK(int request_id); | 68 void OnUploadProgressACK(int request_id); |
62 | 69 |
(...skipping 10 matching lines...) Expand all Loading... |
73 ResourceDispatcherHostImpl* rdh_; | 80 ResourceDispatcherHostImpl* rdh_; |
74 | 81 |
75 // Number of messages we've sent to the renderer that we haven't gotten an | 82 // 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. | 83 // ACK for. This allows us to avoid having too many messages in flight. |
77 int pending_data_count_; | 84 int pending_data_count_; |
78 | 85 |
79 int allocation_size_; | 86 int allocation_size_; |
80 | 87 |
81 bool first_chunk_read_ = false; | 88 bool first_chunk_read_ = false; |
82 | 89 |
83 bool did_defer_; | |
84 | |
85 bool has_checked_for_sufficient_resources_; | 90 bool has_checked_for_sufficient_resources_; |
86 bool sent_received_response_msg_; | 91 bool sent_received_response_msg_; |
87 bool sent_data_buffer_msg_; | 92 bool sent_data_buffer_msg_; |
88 | 93 |
89 std::unique_ptr<InliningHelper> inlining_helper_; | 94 std::unique_ptr<InliningHelper> inlining_helper_; |
90 base::TimeTicks response_started_ticks_; | 95 base::TimeTicks response_started_ticks_; |
91 | 96 |
92 std::unique_ptr<UploadProgressTracker> upload_progress_tracker_; | 97 std::unique_ptr<UploadProgressTracker> upload_progress_tracker_; |
93 | 98 |
94 int64_t reported_transfer_size_; | 99 int64_t reported_transfer_size_; |
95 | 100 |
96 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); | 101 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); |
97 }; | 102 }; |
98 | 103 |
99 } // namespace content | 104 } // namespace content |
100 | 105 |
101 #endif // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ | 106 #endif // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ |
OLD | NEW |