Chromium Code Reviews| 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 <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" |
| 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 "mojo/public/cpp/system/data_pipe.h" | |
| 17 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
| 18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 class URLRequest; | 22 class URLRequest; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 class ResourceBuffer; | 26 class ResourceBuffer; |
| 26 class ResourceContext; | 27 class ResourceContext; |
| 27 class ResourceDispatcherHostImpl; | 28 class ResourceDispatcherHostImpl; |
| 28 class ResourceMessageFilter; | 29 class ResourceMessageFilter; |
| 29 class SharedIOBuffer; | 30 class SharedIOBuffer; |
| 30 | 31 |
| 31 // Used to complete an asynchronous resource request in response to resource | 32 // Used to complete an asynchronous resource request in response to resource |
| 32 // load events from the resource dispatcher host. | 33 // load events from the resource dispatcher host. |
| 33 class AsyncResourceHandler : public ResourceHandler, | 34 class AsyncResourceHandler : public ResourceHandler, |
| 34 public ResourceMessageDelegate { | 35 public ResourceMessageDelegate { |
| 35 public: | 36 public: |
| 36 AsyncResourceHandler(net::URLRequest* request, | 37 AsyncResourceHandler(net::URLRequest* request, |
| 37 ResourceDispatcherHostImpl* rdh); | 38 ResourceDispatcherHostImpl* rdh, |
| 39 bool using_mojo_data_handle); | |
| 38 ~AsyncResourceHandler() override; | 40 ~AsyncResourceHandler() override; |
| 39 | 41 |
| 40 bool OnMessageReceived(const IPC::Message& message) override; | 42 bool OnMessageReceived(const IPC::Message& message) override; |
| 41 | 43 |
| 42 // ResourceHandler implementation: | 44 // ResourceHandler implementation: |
| 43 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, | 45 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, |
| 44 ResourceResponse* response, | 46 ResourceResponse* response, |
| 45 bool* defer) override; | 47 bool* defer) override; |
| 46 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; | 48 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; |
| 47 bool OnWillStart(const GURL& url, bool* defer) override; | 49 bool OnWillStart(const GURL& url, bool* defer) override; |
| 48 bool OnBeforeNetworkStart(const GURL& url, bool* defer) override; | 50 bool OnBeforeNetworkStart(const GURL& url, bool* defer) override; |
| 49 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 51 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| 50 int* buf_size, | 52 int* buf_size, |
| 51 int min_size) override; | 53 int min_size) override; |
| 52 bool OnReadCompleted(int bytes_read, bool* defer) override; | 54 bool OnReadCompleted(int bytes_read, bool* defer) override; |
| 53 void OnResponseCompleted(const net::URLRequestStatus& status, | 55 void OnResponseCompleted(const net::URLRequestStatus& status, |
| 54 const std::string& security_info, | 56 const std::string& security_info, |
| 55 bool* defer) override; | 57 bool* defer) override; |
| 56 void OnDataDownloaded(int bytes_downloaded) override; | 58 void OnDataDownloaded(int bytes_downloaded) override; |
| 57 | 59 |
| 58 private: | 60 private: |
| 59 class InliningHelper; | 61 class InliningHelper; |
| 62 class MojoHelper; | |
| 60 | 63 |
| 61 // IPC message handlers: | 64 // IPC message handlers: |
| 62 void OnFollowRedirect(int request_id); | 65 void OnFollowRedirect(int request_id); |
| 63 void OnDataReceivedACK(int request_id); | 66 void OnDataReceivedACK(int request_id); |
| 64 void OnUploadProgressACK(int request_id); | 67 void OnUploadProgressACK(int request_id); |
| 65 | 68 |
| 66 void ReportUploadProgress(); | 69 void ReportUploadProgress(); |
| 67 | 70 |
| 68 bool EnsureResourceBufferIsInitialized(); | 71 bool EnsureResourceBufferIsInitialized(); |
| 69 void ResumeIfDeferred(); | 72 void ResumeIfDeferred(); |
| 70 void OnDefer(); | 73 void OnDefer(); |
| 71 bool CheckForSufficientResource(); | 74 bool CheckForSufficientResource(); |
| 72 int CalculateEncodedDataLengthToReport(); | 75 int CalculateEncodedDataLengthToReport(); |
| 73 void RecordHistogram(); | 76 void RecordHistogram(); |
| 77 void OnWritable(MojoResult result); | |
|
mmenke
2016/05/23 17:34:53
This method doesn't exist.
yhirano
2016/05/24 06:40:03
Thanks, done.
| |
| 74 | 78 |
| 75 scoped_refptr<ResourceBuffer> buffer_; | 79 scoped_refptr<ResourceBuffer> buffer_; |
| 76 ResourceDispatcherHostImpl* rdh_; | 80 ResourceDispatcherHostImpl* rdh_; |
| 77 | 81 |
| 78 // 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 |
| 79 // 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. |
| 80 int pending_data_count_; | 84 int pending_data_count_; |
| 81 | 85 |
| 82 int allocation_size_; | 86 int allocation_size_; |
| 83 | 87 |
| 84 bool did_defer_; | 88 bool did_defer_; |
| 85 | 89 |
| 86 bool has_checked_for_sufficient_resources_; | 90 bool has_checked_for_sufficient_resources_; |
| 87 bool sent_received_response_msg_; | 91 bool sent_received_response_msg_; |
| 88 bool sent_data_buffer_msg_; | 92 bool sent_data_buffer_msg_; |
| 93 bool using_mojo_data_handle_; | |
| 89 | 94 |
| 90 std::unique_ptr<InliningHelper> inlining_helper_; | 95 std::unique_ptr<InliningHelper> inlining_helper_; |
| 91 base::TimeTicks response_started_ticks_; | 96 base::TimeTicks response_started_ticks_; |
| 92 | 97 |
| 93 uint64_t last_upload_position_; | 98 uint64_t last_upload_position_; |
| 94 bool waiting_for_upload_progress_ack_; | 99 bool waiting_for_upload_progress_ack_; |
| 95 base::TimeTicks last_upload_ticks_; | 100 base::TimeTicks last_upload_ticks_; |
| 96 base::RepeatingTimer progress_timer_; | 101 base::RepeatingTimer progress_timer_; |
| 97 | 102 |
| 98 int64_t reported_transfer_size_; | 103 int64_t reported_transfer_size_; |
| 99 | 104 |
| 105 std::unique_ptr<MojoHelper> mojo_helper_; | |
| 106 | |
| 100 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); | 107 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); |
| 101 }; | 108 }; |
| 102 | 109 |
| 103 } // namespace content | 110 } // namespace content |
| 104 | 111 |
| 105 #endif // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ | 112 #endif // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ |
| OLD | NEW |