Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Side by Side Diff: content/browser/loader/intercepting_resource_handler.h

Issue 2366753002: Have MimeSniffingResourceHandler call WillStartRequest on new Handlers. (Closed)
Patch Set: Fix Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/loader/intercepting_resource_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 // ResourceHandler implementation: 35 // ResourceHandler implementation:
36 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; 36 bool OnResponseStarted(ResourceResponse* response, bool* defer) override;
37 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, 37 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf,
38 int* buf_size, 38 int* buf_size,
39 int min_size) override; 39 int min_size) override;
40 bool OnReadCompleted(int bytes_read, bool* defer) override; 40 bool OnReadCompleted(int bytes_read, bool* defer) override;
41 41
42 // Replaces the next handler with |new_handler|, sending 42 // Replaces the next handler with |new_handler|, sending
43 // |payload_for_old_handler| to the old handler. Must be called after 43 // |payload_for_old_handler| to the old handler. Must be called after
44 // OnWillStart and OnRequestRedirected and before OnResponseStarted. One 44 // OnWillStart and OnRequestRedirected and before OnResponseStarted. One
45 // OnWillRead call is permitted beforehand. |new_handler|'s OnWillStart and 45 // OnWillRead call is permitted beforehand. |new_handler| is assumed to
46 // OnRequestRedirected methods will not be called. 46 // be advanced to a state where it can take the place of the old handler
47 // (The InterceptingResourceHandler won't call OnWillStart or
48 // OnRequestRedirected, but will pass along newly read data).
47 void UseNewHandler(std::unique_ptr<ResourceHandler> new_handler, 49 void UseNewHandler(std::unique_ptr<ResourceHandler> new_handler,
48 const std::string& payload_for_old_handler); 50 const std::string& payload_for_old_handler);
49 51
50 // Used in tests. 52 // Used in tests.
51 ResourceHandler* new_handler_for_testing() const { 53 ResourceHandler* next_handler_for_testing() const {
52 return new_handler_.get(); 54 return next_handler_.get();
53 } 55 }
54 56
55 private: 57 private:
56 enum class State { 58 enum class State {
57 // In this state, the InterceptingResourceHandler is waiting for the mime 59 // In this state, the InterceptingResourceHandler is waiting for the mime
58 // type of the response to be identified, to check if the next handler 60 // type of the response to be identified, to check if the next handler
59 // should be replaced with an appropriate one. 61 // should be replaced with an appropriate one.
60 STARTING, 62 STARTING,
61 63
62 // In this state, the InterceptingResourceHandler is waiting to copy the 64 // In this state, the InterceptingResourceHandler is waiting to copy the
(...skipping 23 matching lines...) Expand all
86 scoped_refptr<net::IOBuffer> first_read_buffer_; 88 scoped_refptr<net::IOBuffer> first_read_buffer_;
87 size_t first_read_buffer_size_; 89 size_t first_read_buffer_size_;
88 scoped_refptr<net::IOBuffer> first_read_buffer_copy_; 90 scoped_refptr<net::IOBuffer> first_read_buffer_copy_;
89 91
90 DISALLOW_COPY_AND_ASSIGN(InterceptingResourceHandler); 92 DISALLOW_COPY_AND_ASSIGN(InterceptingResourceHandler);
91 }; 93 };
92 94
93 } // namespace content 95 } // namespace content
94 96
95 #endif // CONTENT_BROWSER_LOADER_INTERCEPTING_RESOURCE_HANDLER_H_ 97 #endif // CONTENT_BROWSER_LOADER_INTERCEPTING_RESOURCE_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/loader/intercepting_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698