| 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" |  | 
| 15 #include "content/browser/loader/resource_handler.h" | 14 #include "content/browser/loader/resource_handler.h" | 
| 16 #include "content/browser/loader/resource_message_delegate.h" | 15 #include "content/browser/loader/resource_message_delegate.h" | 
| 17 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" | 
| 18 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" | 
| 19 #include "url/gurl.h" | 18 #include "url/gurl.h" | 
| 20 | 19 | 
| 21 namespace net { | 20 namespace net { | 
| 22 class URLRequest; | 21 class URLRequest; | 
| 23 } | 22 } | 
| 24 | 23 | 
| 25 namespace content { | 24 namespace content { | 
| 26 class ResourceBuffer; | 25 class ResourceBuffer; | 
| 27 class ResourceDispatcherHostImpl; | 26 class ResourceDispatcherHostImpl; | 
|  | 27 class UploadProgressTracker; | 
| 28 | 28 | 
| 29 // Used to complete an asynchronous resource request in response to resource | 29 // Used to complete an asynchronous resource request in response to resource | 
| 30 // load events from the resource dispatcher host. | 30 // load events from the resource dispatcher host. | 
| 31 class CONTENT_EXPORT AsyncResourceHandler : public ResourceHandler, | 31 class CONTENT_EXPORT AsyncResourceHandler : public ResourceHandler, | 
| 32                                             public ResourceMessageDelegate { | 32                                             public ResourceMessageDelegate { | 
| 33  public: | 33  public: | 
| 34   AsyncResourceHandler(net::URLRequest* request, | 34   AsyncResourceHandler(net::URLRequest* request, | 
| 35                        ResourceDispatcherHostImpl* rdh); | 35                        ResourceDispatcherHostImpl* rdh); | 
| 36   ~AsyncResourceHandler() override; | 36   ~AsyncResourceHandler() override; | 
| 37 | 37 | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 52   void OnDataDownloaded(int bytes_downloaded) override; | 52   void OnDataDownloaded(int bytes_downloaded) override; | 
| 53 | 53 | 
| 54  private: | 54  private: | 
| 55   class InliningHelper; | 55   class InliningHelper; | 
| 56 | 56 | 
| 57   // IPC message handlers: | 57   // IPC message handlers: | 
| 58   void OnFollowRedirect(int request_id); | 58   void OnFollowRedirect(int request_id); | 
| 59   void OnDataReceivedACK(int request_id); | 59   void OnDataReceivedACK(int request_id); | 
| 60   void OnUploadProgressACK(int request_id); | 60   void OnUploadProgressACK(int request_id); | 
| 61 | 61 | 
| 62   void ReportUploadProgress(); |  | 
| 63 |  | 
| 64   bool EnsureResourceBufferIsInitialized(); | 62   bool EnsureResourceBufferIsInitialized(); | 
| 65   void ResumeIfDeferred(); | 63   void ResumeIfDeferred(); | 
| 66   void OnDefer(); | 64   void OnDefer(); | 
| 67   bool CheckForSufficientResource(); | 65   bool CheckForSufficientResource(); | 
| 68   int CalculateEncodedDataLengthToReport(); | 66   int CalculateEncodedDataLengthToReport(); | 
| 69   int CalculateEncodedBodyLengthToReport(); | 67   int CalculateEncodedBodyLengthToReport(); | 
| 70   void RecordHistogram(); | 68   void RecordHistogram(); | 
| 71 | 69 | 
| 72   scoped_refptr<ResourceBuffer> buffer_; | 70   scoped_refptr<ResourceBuffer> buffer_; | 
| 73   ResourceDispatcherHostImpl* rdh_; | 71   ResourceDispatcherHostImpl* rdh_; | 
| 74 | 72 | 
| 75   // Number of messages we've sent to the renderer that we haven't gotten an | 73   // 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. | 74   // ACK for. This allows us to avoid having too many messages in flight. | 
| 77   int pending_data_count_; | 75   int pending_data_count_; | 
| 78 | 76 | 
| 79   int allocation_size_; | 77   int allocation_size_; | 
| 80 | 78 | 
| 81   bool first_chunk_read_ = false; | 79   bool first_chunk_read_ = false; | 
| 82 | 80 | 
| 83   bool did_defer_; | 81   bool did_defer_; | 
| 84 | 82 | 
| 85   bool has_checked_for_sufficient_resources_; | 83   bool has_checked_for_sufficient_resources_; | 
| 86   bool sent_received_response_msg_; | 84   bool sent_received_response_msg_; | 
| 87   bool sent_data_buffer_msg_; | 85   bool sent_data_buffer_msg_; | 
| 88 | 86 | 
| 89   std::unique_ptr<InliningHelper> inlining_helper_; | 87   std::unique_ptr<InliningHelper> inlining_helper_; | 
| 90   base::TimeTicks response_started_ticks_; | 88   base::TimeTicks response_started_ticks_; | 
| 91 | 89 | 
| 92   uint64_t last_upload_position_; | 90   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 | 91 | 
| 97   int64_t reported_transfer_size_; | 92   int64_t reported_transfer_size_; | 
| 98 | 93 | 
| 99   DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); | 94   DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); | 
| 100 }; | 95 }; | 
| 101 | 96 | 
| 102 }  // namespace content | 97 }  // namespace content | 
| 103 | 98 | 
| 104 #endif  // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ | 99 #endif  // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ | 
| OLD | NEW | 
|---|