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

Side by Side Diff: net/url_request/sdch_dictionary_fetcher.h

Issue 1880283002: Disallow redirects in SDCH dictionary fetches. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
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 // TODO(rdsmith): This class needs to delegate URLRequest::Delegate methods 5 // TODO(rdsmith): This class needs to delegate URLRequest::Delegate methods
6 // to the net/ embedder for correct implementation of authentication. 6 // to the net/ embedder for correct implementation of authentication.
7 // Specifically, this class needs the embedder to provide functionality 7 // Specifically, this class needs the embedder to provide functionality
8 // corresponding to 8 // corresponding to
9 // URLRequest::Delegate::{OnAuthRequired,OnCertificateRequested}. 9 // URLRequest::Delegate::{OnAuthRequired,OnCertificateRequested}.
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // Request a dictionary fetch from cache only. The callback will be called 55 // Request a dictionary fetch from cache only. The callback will be called
56 // only if the dictionary is successfully fetched. Returns true if a request 56 // only if the dictionary is successfully fetched. Returns true if a request
57 // for |dictionary_url| has been scheduled, and false otherwise. 57 // for |dictionary_url| has been scheduled, and false otherwise.
58 virtual bool ScheduleReload(const GURL& dictionary_url, 58 virtual bool ScheduleReload(const GURL& dictionary_url,
59 const OnDictionaryFetchedCallback& callback); 59 const OnDictionaryFetchedCallback& callback);
60 60
61 // Cancel any in-progress requests. 61 // Cancel any in-progress requests.
62 virtual void Cancel(); 62 virtual void Cancel();
63 63
64 // Implementation of URLRequest::Delegate methods. 64 // Implementation of URLRequest::Delegate methods.
65 void OnReceivedRedirect(URLRequest* request,
66 const RedirectInfo& redirect_info,
67 bool* defer_redirect) override;
65 void OnResponseStarted(URLRequest* request) override; 68 void OnResponseStarted(URLRequest* request) override;
66 void OnReadCompleted(URLRequest* request, int bytes_read) override; 69 void OnReadCompleted(URLRequest* request, int bytes_read) override;
67 70
68 private: 71 private:
69 enum State { 72 enum State {
70 STATE_NONE, 73 STATE_NONE,
71 STATE_SEND_REQUEST, 74 STATE_SEND_REQUEST,
72 STATE_SEND_REQUEST_COMPLETE, 75 STATE_RECEIVED_REDIRECT,
76 STATE_SEND_REQUEST_PENDING,
73 STATE_READ_BODY, 77 STATE_READ_BODY,
74 STATE_READ_BODY_COMPLETE, 78 STATE_READ_BODY_COMPLETE,
75 STATE_REQUEST_COMPLETE, 79 STATE_REQUEST_COMPLETE,
76 }; 80 };
77 81
78 class UniqueFetchQueue; 82 class UniqueFetchQueue;
79 83
80 // Schedule implementation. Returns true if a request for |dictionary_url| has 84 // Schedule implementation. Returns true if a request for |dictionary_url| has
81 // been added to the queue, and false otherwise. 85 // been added to the queue, and false otherwise.
82 bool ScheduleInternal(const GURL& dictionary_url, 86 bool ScheduleInternal(const GURL& dictionary_url,
83 bool reload, 87 bool reload,
84 const OnDictionaryFetchedCallback& callback); 88 const OnDictionaryFetchedCallback& callback);
85 89
86 // Null out the current request and push the state machine to the 90 // Null out the current request and push the state machine to the
87 // next request, if any. 91 // next request, if any.
88 void ResetRequest(); 92 void ResetRequest();
89 93
90 // State machine implementation. 94 // State machine implementation.
91 int DoLoop(int rv); 95 int DoLoop(int rv);
92 int DoSendRequest(int rv); 96 int DoSendRequest(int rv);
93 int DoSendRequestComplete(int rv); 97 int DoReceivedRedirect(int rv);
98 int DoSendRequestPending(int rv);
94 int DoReadBody(int rv); 99 int DoReadBody(int rv);
95 int DoReadBodyComplete(int rv); 100 int DoReadBodyComplete(int rv);
96 int DoCompleteRequest(int rv); 101 int DoCompleteRequest(int rv);
97 102
98 State next_state_; 103 State next_state_;
99 bool in_loop_; 104 bool in_loop_;
100 105
101 // A queue of URLs that are being used to download dictionaries. 106 // A queue of URLs that are being used to download dictionaries.
102 scoped_ptr<UniqueFetchQueue> fetch_queue_; 107 scoped_ptr<UniqueFetchQueue> fetch_queue_;
103 108
104 // The request, buffer, and consumer supplied data used for getting 109 // The request, buffer, and consumer supplied data used for getting
105 // the current dictionary. All are null when a fetch is not in progress. 110 // the current dictionary. All are null when a fetch is not in progress.
106 scoped_ptr<URLRequest> current_request_; 111 scoped_ptr<URLRequest> current_request_;
107 scoped_refptr<IOBuffer> buffer_; 112 scoped_refptr<IOBuffer> buffer_;
108 OnDictionaryFetchedCallback current_callback_; 113 OnDictionaryFetchedCallback current_callback_;
109 114
110 // The currently accumulating dictionary. 115 // The currently accumulating dictionary.
111 std::string dictionary_; 116 std::string dictionary_;
112 117
118 // In the case of a redirect, the URL to which the request is being
119 // redirected.
120 GURL redirect_url_;
121
113 // Store the URLRequestContext associated with the owning SdchManager for 122 // Store the URLRequestContext associated with the owning SdchManager for
114 // use while fetching. 123 // use while fetching.
115 URLRequestContext* const context_; 124 URLRequestContext* const context_;
116 125
117 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); 126 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher);
118 }; 127 };
119 128
120 } // namespace net 129 } // namespace net
121 130
122 #endif // NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_ 131 #endif // NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_
OLDNEW
« no previous file with comments | « no previous file | net/url_request/sdch_dictionary_fetcher.cc » ('j') | net/url_request/sdch_dictionary_fetcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698