| 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/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 16 #include "content/browser/loader/resource_handler.h" | 17 #include "content/browser/loader/resource_handler.h" |
| 17 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 18 #include "content/common/url_loader.mojom.h" | 19 #include "content/common/url_loader.mojom.h" |
| 19 #include "mojo/public/cpp/bindings/associated_binding.h" | 20 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 20 #include "mojo/public/cpp/system/watcher.h" | 21 #include "mojo/public/cpp/system/watcher.h" |
| 21 #include "net/base/io_buffer.h" | 22 #include "net/base/io_buffer.h" |
| 22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 23 | 24 |
| 24 namespace net { | 25 namespace net { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // successfully. | 87 // successfully. |
| 87 bool AllocateWriterIOBuffer(scoped_refptr<net::IOBufferWithSize>* buf, | 88 bool AllocateWriterIOBuffer(scoped_refptr<net::IOBufferWithSize>* buf, |
| 88 bool* defer); | 89 bool* defer); |
| 89 | 90 |
| 90 bool CheckForSufficientResource(); | 91 bool CheckForSufficientResource(); |
| 91 void OnWritable(MojoResult result); | 92 void OnWritable(MojoResult result); |
| 92 void Cancel(); | 93 void Cancel(); |
| 93 // This function can be overriden only for tests. | 94 // This function can be overriden only for tests. |
| 94 virtual void ReportBadMessage(const std::string& error); | 95 virtual void ReportBadMessage(const std::string& error); |
| 95 | 96 |
| 97 void OnTransfer(mojom::URLLoaderAssociatedRequest mojo_request, |
| 98 mojom::URLLoaderClientAssociatedPtr url_loader_client); |
| 99 |
| 96 ResourceDispatcherHostImpl* rdh_; | 100 ResourceDispatcherHostImpl* rdh_; |
| 97 mojo::AssociatedBinding<mojom::URLLoader> binding_; | 101 mojo::AssociatedBinding<mojom::URLLoader> binding_; |
| 98 | 102 |
| 99 bool has_checked_for_sufficient_resources_ = false; | 103 bool has_checked_for_sufficient_resources_ = false; |
| 100 bool sent_received_response_message_ = false; | 104 bool sent_received_response_message_ = false; |
| 101 bool is_using_io_buffer_not_from_writer_ = false; | 105 bool is_using_io_buffer_not_from_writer_ = false; |
| 102 bool did_defer_on_writing_ = false; | 106 bool did_defer_on_writing_ = false; |
| 103 bool did_defer_on_redirect_ = false; | 107 bool did_defer_on_redirect_ = false; |
| 104 base::TimeTicks response_started_ticks_; | 108 base::TimeTicks response_started_ticks_; |
| 105 int64_t reported_total_received_bytes_ = 0; | 109 int64_t reported_total_received_bytes_ = 0; |
| 106 | 110 |
| 107 mojo::Watcher handle_watcher_; | 111 mojo::Watcher handle_watcher_; |
| 108 std::unique_ptr<mojom::URLLoader> url_loader_; | 112 std::unique_ptr<mojom::URLLoader> url_loader_; |
| 109 mojom::URLLoaderClientAssociatedPtr url_loader_client_; | 113 mojom::URLLoaderClientAssociatedPtr url_loader_client_; |
| 110 scoped_refptr<net::IOBufferWithSize> buffer_; | 114 scoped_refptr<net::IOBufferWithSize> buffer_; |
| 111 size_t buffer_offset_ = 0; | 115 size_t buffer_offset_ = 0; |
| 112 size_t buffer_bytes_read_ = 0; | 116 size_t buffer_bytes_read_ = 0; |
| 113 scoped_refptr<SharedWriter> shared_writer_; | 117 scoped_refptr<SharedWriter> shared_writer_; |
| 114 | 118 |
| 119 base::WeakPtrFactory<MojoAsyncResourceHandler> weak_factory_; |
| 115 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); | 120 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); |
| 116 }; | 121 }; |
| 117 | 122 |
| 118 } // namespace content | 123 } // namespace content |
| 119 | 124 |
| 120 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ | 125 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ |
| OLD | NEW |