| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_MOJO_ASYNC_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_LOADER_MOJO_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 "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "content/browser/loader/resource_handler.h" | 16 #include "content/browser/loader/resource_handler.h" |
| 17 #include "content/browser/loader/upload_progress_tracker.h" | 17 #include "content/browser/loader/upload_progress_tracker.h" |
| 18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "content/common/url_loader.mojom.h" | 19 #include "content/common/url_loader.mojom.h" |
| 20 #include "content/public/common/resource_type.h" | 20 #include "content/public/common/resource_type.h" |
| 21 #include "mojo/public/cpp/bindings/associated_binding.h" | 21 #include "mojo/public/cpp/bindings/binding.h" |
| 22 #include "mojo/public/cpp/system/data_pipe.h" | 22 #include "mojo/public/cpp/system/data_pipe.h" |
| 23 #include "mojo/public/cpp/system/simple_watcher.h" | 23 #include "mojo/public/cpp/system/simple_watcher.h" |
| 24 #include "net/base/io_buffer.h" | 24 #include "net/base/io_buffer.h" |
| 25 #include "net/base/request_priority.h" | 25 #include "net/base/request_priority.h" |
| 26 | 26 |
| 27 class GURL; | 27 class GURL; |
| 28 | 28 |
| 29 namespace tracked_objects { | 29 namespace tracked_objects { |
| 30 class Location; | 30 class Location; |
| 31 } | 31 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 47 // TODO(yhirano): Add histograms. | 47 // TODO(yhirano): Add histograms. |
| 48 // TODO(yhirano): Send cached metadata. | 48 // TODO(yhirano): Send cached metadata. |
| 49 // | 49 // |
| 50 // This class can be inherited only for tests. | 50 // This class can be inherited only for tests. |
| 51 class CONTENT_EXPORT MojoAsyncResourceHandler | 51 class CONTENT_EXPORT MojoAsyncResourceHandler |
| 52 : public ResourceHandler, | 52 : public ResourceHandler, |
| 53 public NON_EXPORTED_BASE(mojom::URLLoader) { | 53 public NON_EXPORTED_BASE(mojom::URLLoader) { |
| 54 public: | 54 public: |
| 55 MojoAsyncResourceHandler(net::URLRequest* request, | 55 MojoAsyncResourceHandler(net::URLRequest* request, |
| 56 ResourceDispatcherHostImpl* rdh, | 56 ResourceDispatcherHostImpl* rdh, |
| 57 mojom::URLLoaderAssociatedRequest mojo_request, | 57 mojom::URLLoaderRequest mojo_request, |
| 58 mojom::URLLoaderClientPtr url_loader_client, | 58 mojom::URLLoaderClientPtr url_loader_client, |
| 59 ResourceType resource_type); | 59 ResourceType resource_type); |
| 60 ~MojoAsyncResourceHandler() override; | 60 ~MojoAsyncResourceHandler() override; |
| 61 | 61 |
| 62 // ResourceHandler implementation: | 62 // ResourceHandler implementation: |
| 63 void OnRequestRedirected( | 63 void OnRequestRedirected( |
| 64 const net::RedirectInfo& redirect_info, | 64 const net::RedirectInfo& redirect_info, |
| 65 ResourceResponse* response, | 65 ResourceResponse* response, |
| 66 std::unique_ptr<ResourceController> controller) override; | 66 std::unique_ptr<ResourceController> controller) override; |
| 67 void OnResponseStarted( | 67 void OnResponseStarted( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // |reported_total_received_bytes_|, returns it, and updates | 114 // |reported_total_received_bytes_|, returns it, and updates |
| 115 // |reported_total_received_bytes_|. | 115 // |reported_total_received_bytes_|. |
| 116 int64_t CalculateRecentlyReceivedBytes(); | 116 int64_t CalculateRecentlyReceivedBytes(); |
| 117 | 117 |
| 118 // These functions can be overriden only for tests. | 118 // These functions can be overriden only for tests. |
| 119 virtual void ReportBadMessage(const std::string& error); | 119 virtual void ReportBadMessage(const std::string& error); |
| 120 virtual std::unique_ptr<UploadProgressTracker> CreateUploadProgressTracker( | 120 virtual std::unique_ptr<UploadProgressTracker> CreateUploadProgressTracker( |
| 121 const tracked_objects::Location& from_here, | 121 const tracked_objects::Location& from_here, |
| 122 UploadProgressTracker::UploadProgressReportCallback callback); | 122 UploadProgressTracker::UploadProgressReportCallback callback); |
| 123 | 123 |
| 124 void OnTransfer(mojom::URLLoaderAssociatedRequest mojo_request, | 124 void OnTransfer(mojom::URLLoaderRequest mojo_request, |
| 125 mojom::URLLoaderClientPtr url_loader_client); | 125 mojom::URLLoaderClientPtr url_loader_client); |
| 126 void SendUploadProgress(const net::UploadProgress& progress); | 126 void SendUploadProgress(const net::UploadProgress& progress); |
| 127 void OnUploadProgressACK(); | 127 void OnUploadProgressACK(); |
| 128 | 128 |
| 129 ResourceDispatcherHostImpl* rdh_; | 129 ResourceDispatcherHostImpl* rdh_; |
| 130 mojo::AssociatedBinding<mojom::URLLoader> binding_; | 130 mojo::Binding<mojom::URLLoader> binding_; |
| 131 | 131 |
| 132 bool has_checked_for_sufficient_resources_ = false; | 132 bool has_checked_for_sufficient_resources_ = false; |
| 133 bool sent_received_response_message_ = false; | 133 bool sent_received_response_message_ = false; |
| 134 bool is_using_io_buffer_not_from_writer_ = false; | 134 bool is_using_io_buffer_not_from_writer_ = false; |
| 135 // True if OnWillRead was deferred, in order to wait to be able to allocate a | 135 // True if OnWillRead was deferred, in order to wait to be able to allocate a |
| 136 // buffer. | 136 // buffer. |
| 137 bool did_defer_on_will_read_ = false; | 137 bool did_defer_on_will_read_ = false; |
| 138 bool did_defer_on_writing_ = false; | 138 bool did_defer_on_writing_ = false; |
| 139 bool did_defer_on_redirect_ = false; | 139 bool did_defer_on_redirect_ = false; |
| 140 base::TimeTicks response_started_ticks_; | 140 base::TimeTicks response_started_ticks_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 157 | 157 |
| 158 std::unique_ptr<UploadProgressTracker> upload_progress_tracker_; | 158 std::unique_ptr<UploadProgressTracker> upload_progress_tracker_; |
| 159 | 159 |
| 160 base::WeakPtrFactory<MojoAsyncResourceHandler> weak_factory_; | 160 base::WeakPtrFactory<MojoAsyncResourceHandler> weak_factory_; |
| 161 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); | 161 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 } // namespace content | 164 } // namespace content |
| 165 | 165 |
| 166 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ | 166 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ |
| OLD | NEW |