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_INTERCEPTING_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_INTERCEPTING_RESOURCE_HANDLER_H_ |
6 #define CONTENT_BROWSER_LOADER_INTERCEPTING_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_LOADER_INTERCEPTING_RESOURCE_HANDLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // Runs necessary operations depending on |state_|. Returns false when an | 111 // Runs necessary operations depending on |state_|. Returns false when an |
112 // error happens, and set |*defer| to true if the operation continues upon | 112 // error happens, and set |*defer| to true if the operation continues upon |
113 // return. | 113 // return. |
114 bool DoLoop(bool* defer); | 114 bool DoLoop(bool* defer); |
115 | 115 |
116 // The return value and |defer| has the same meaning as DoLoop. | 116 // The return value and |defer| has the same meaning as DoLoop. |
117 bool SendPayloadToOldHandler(bool* defer); | 117 bool SendPayloadToOldHandler(bool* defer); |
118 bool SendFirstReadBufferToNewHandler(bool* defer); | 118 bool SendFirstReadBufferToNewHandler(bool* defer); |
119 bool SendOnResponseStartedToNewHandler(bool* defer); | 119 bool SendOnResponseStartedToNewHandler(bool* defer); |
120 | 120 |
| 121 // Wraps calls to DoLoop. Resumes or Cancels underlying request, if needed. |
| 122 void AdvanceState(); |
| 123 |
121 State state_ = State::STARTING; | 124 State state_ = State::STARTING; |
122 | 125 |
123 std::unique_ptr<ResourceHandler> new_handler_; | 126 std::unique_ptr<ResourceHandler> new_handler_; |
124 std::string payload_for_old_handler_; | 127 std::string payload_for_old_handler_; |
125 size_t payload_bytes_written_ = 0; | 128 size_t payload_bytes_written_ = 0; |
126 | 129 |
127 // Result of the first read, that may have to be passed to an alternate | 130 // Result of the first read, that may have to be passed to an alternate |
128 // ResourceHandler instead of the original ResourceHandler. | 131 // ResourceHandler instead of the original ResourceHandler. |
129 scoped_refptr<net::IOBuffer> first_read_buffer_; | 132 scoped_refptr<net::IOBuffer> first_read_buffer_; |
130 // Instead of |first_read_buffer_|, this handler creates a new IOBuffer with | 133 // Instead of |first_read_buffer_|, this handler creates a new IOBuffer with |
131 // the same size and return it to the client. | 134 // the same size and return it to the client. |
132 scoped_refptr<net::IOBuffer> first_read_buffer_double_; | 135 scoped_refptr<net::IOBuffer> first_read_buffer_double_; |
133 size_t first_read_buffer_size_ = 0; | 136 size_t first_read_buffer_size_ = 0; |
134 size_t first_read_buffer_bytes_read_ = 0; | 137 size_t first_read_buffer_bytes_read_ = 0; |
135 size_t first_read_buffer_bytes_written_ = 0; | 138 size_t first_read_buffer_bytes_written_ = 0; |
136 | 139 |
137 scoped_refptr<ResourceResponse> response_; | 140 scoped_refptr<ResourceResponse> response_; |
138 | 141 |
| 142 base::WeakPtrFactory<InterceptingResourceHandler> weak_ptr_factory_; |
| 143 |
139 DISALLOW_COPY_AND_ASSIGN(InterceptingResourceHandler); | 144 DISALLOW_COPY_AND_ASSIGN(InterceptingResourceHandler); |
140 }; | 145 }; |
141 | 146 |
142 } // namespace content | 147 } // namespace content |
143 | 148 |
144 #endif // CONTENT_BROWSER_LOADER_INTERCEPTING_RESOURCE_HANDLER_H_ | 149 #endif // CONTENT_BROWSER_LOADER_INTERCEPTING_RESOURCE_HANDLER_H_ |
OLD | NEW |