| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_NAVIGATION_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "content/browser/loader/resource_handler.h" | 11 #include "content/browser/loader/resource_handler.h" |
| 12 #include "content/browser/loader/stream_writer.h" | 12 #include "mojo/public/cpp/system/data_pipe.h" |
| 13 #include "mojo/public/cpp/system/simple_watcher.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 class SSLInfo; | 16 class SSLInfo; |
| 17 class IOBufferWithSize; |
| 16 } | 18 } |
| 17 | 19 |
| 18 namespace content { | 20 namespace content { |
| 19 class NavigationURLLoaderImplCore; | 21 class NavigationURLLoaderImplCore; |
| 20 class ResourceController; | 22 class ResourceController; |
| 21 class ResourceDispatcherHostDelegate; | 23 class ResourceDispatcherHostDelegate; |
| 22 struct SSLStatus; | 24 struct SSLStatus; |
| 23 | 25 |
| 24 // PlzNavigate: The leaf ResourceHandler used with NavigationURLLoaderImplCore. | 26 // PlzNavigate: The leaf ResourceHandler used with NavigationURLLoaderImplCore. |
| 25 class NavigationResourceHandler : public ResourceHandler { | 27 class NavigationResourceHandler : public ResourceHandler { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 int* buf_size, | 60 int* buf_size, |
| 59 std::unique_ptr<ResourceController> controller) override; | 61 std::unique_ptr<ResourceController> controller) override; |
| 60 void OnReadCompleted(int bytes_read, | 62 void OnReadCompleted(int bytes_read, |
| 61 std::unique_ptr<ResourceController> controller) override; | 63 std::unique_ptr<ResourceController> controller) override; |
| 62 void OnResponseCompleted( | 64 void OnResponseCompleted( |
| 63 const net::URLRequestStatus& status, | 65 const net::URLRequestStatus& status, |
| 64 std::unique_ptr<ResourceController> controller) override; | 66 std::unique_ptr<ResourceController> controller) override; |
| 65 void OnDataDownloaded(int bytes_downloaded) override; | 67 void OnDataDownloaded(int bytes_downloaded) override; |
| 66 | 68 |
| 67 private: | 69 private: |
| 70 class SharedWriter; |
| 71 class WriterIOBuffer; |
| 72 |
| 68 // Clears |core_| and its reference to the resource handler. After calling | 73 // Clears |core_| and its reference to the resource handler. After calling |
| 69 // this, the lifetime of the request is no longer tied to |core_|. | 74 // this, the lifetime of the request is no longer tied to |core_|. |
| 70 void DetachFromCore(); | 75 void DetachFromCore(); |
| 71 | 76 |
| 77 void InitializeDataPipe(mojo::ScopedDataPipeConsumerHandle* consumer_handle); |
| 78 virtual MojoResult BeginWrite(void** data, uint32_t* available); |
| 79 virtual MojoResult EndWrite(uint32_t written); |
| 80 bool CopyReadDataToDataPipe(bool* defer); |
| 81 bool AllocateWriterIOBuffer(scoped_refptr<net::IOBufferWithSize>* buf, |
| 82 bool* defer); |
| 83 void OnWritable(MojoResult result); |
| 84 |
| 72 NavigationURLLoaderImplCore* core_; | 85 NavigationURLLoaderImplCore* core_; |
| 73 StreamWriter writer_; | |
| 74 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate_; | 86 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate_; |
| 75 | 87 |
| 88 bool is_using_io_buffer_not_from_writer_ = false; |
| 89 |
| 90 // True if OnWillRead was deferred, in order to wait to be able to allocate a |
| 91 // buffer. |
| 92 bool did_defer_on_will_read_ = false; |
| 93 bool did_defer_on_writing_ = false; |
| 94 bool did_defer_on_redirect_ = false; |
| 95 |
| 96 scoped_refptr<net::IOBuffer>* parent_buffer_ = nullptr; |
| 97 int* parent_buffer_size_ = nullptr; |
| 98 |
| 99 mojo::SimpleWatcher handle_watcher_; |
| 100 scoped_refptr<net::IOBufferWithSize> buffer_; |
| 101 size_t buffer_offset_ = 0; |
| 102 size_t buffer_bytes_read_ = 0; |
| 103 scoped_refptr<SharedWriter> shared_writer_; |
| 104 bool first_read_ = true; |
| 105 |
| 76 DISALLOW_COPY_AND_ASSIGN(NavigationResourceHandler); | 106 DISALLOW_COPY_AND_ASSIGN(NavigationResourceHandler); |
| 77 }; | 107 }; |
| 78 | 108 |
| 79 } // namespace content | 109 } // namespace content |
| 80 | 110 |
| 81 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_ | 111 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_ |
| OLD | NEW |