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

Side by Side Diff: extensions/browser/api/web_request/form_data_parser.cc

Issue 664933004: Standardize usage of virtual/override/final in extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "extensions/browser/api/web_request/form_data_parser.h" 5 #include "extensions/browser/api/web_request/form_data_parser.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 base::LazyInstance<Patterns>::Leaky g_patterns = LAZY_INSTANCE_INITIALIZER; 73 base::LazyInstance<Patterns>::Leaky g_patterns = LAZY_INSTANCE_INITIALIZER;
74 74
75 } // namespace 75 } // namespace
76 76
77 // Parses URLencoded forms, see 77 // Parses URLencoded forms, see
78 // http://www.w3.org/TR/REC-html40-971218/interact/forms.html#h-17.13.4.1 . 78 // http://www.w3.org/TR/REC-html40-971218/interact/forms.html#h-17.13.4.1 .
79 class FormDataParserUrlEncoded : public FormDataParser { 79 class FormDataParserUrlEncoded : public FormDataParser {
80 public: 80 public:
81 FormDataParserUrlEncoded(); 81 FormDataParserUrlEncoded();
82 virtual ~FormDataParserUrlEncoded(); 82 ~FormDataParserUrlEncoded() override;
83 83
84 // Implementation of FormDataParser. 84 // Implementation of FormDataParser.
85 virtual bool AllDataReadOK() override; 85 bool AllDataReadOK() override;
86 virtual bool GetNextNameValue(Result* result) override; 86 bool GetNextNameValue(Result* result) override;
87 virtual bool SetSource(base::StringPiece source) override; 87 bool SetSource(base::StringPiece source) override;
88 88
89 private: 89 private:
90 // Returns the pattern to match a single name-value pair. This could be even 90 // Returns the pattern to match a single name-value pair. This could be even
91 // static, but then we would have to spend more code on initializing the 91 // static, but then we would have to spend more code on initializing the
92 // cached pointer to g_patterns.Get(). 92 // cached pointer to g_patterns.Get().
93 const RE2& pattern() const { 93 const RE2& pattern() const {
94 return patterns_->url_encoded_pattern; 94 return patterns_->url_encoded_pattern;
95 } 95 }
96 96
97 // Auxiliary constant for using RE2. Number of arguments for parsing 97 // Auxiliary constant for using RE2. Number of arguments for parsing
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // 3. The final close-delimiter and epilogue are read and ignored. 183 // 3. The final close-delimiter and epilogue are read and ignored.
184 // 184 //
185 // IMPORTANT NOTE 185 // IMPORTANT NOTE
186 // This parser supports sources split into multiple chunks. Therefore SetSource 186 // This parser supports sources split into multiple chunks. Therefore SetSource
187 // can be called multiple times if the source is spread over several chunks. 187 // can be called multiple times if the source is spread over several chunks.
188 // However, the split may only occur inside a body part, right after the 188 // However, the split may only occur inside a body part, right after the
189 // trailing CRLF of headers. 189 // trailing CRLF of headers.
190 class FormDataParserMultipart : public FormDataParser { 190 class FormDataParserMultipart : public FormDataParser {
191 public: 191 public:
192 explicit FormDataParserMultipart(const std::string& boundary_separator); 192 explicit FormDataParserMultipart(const std::string& boundary_separator);
193 virtual ~FormDataParserMultipart(); 193 ~FormDataParserMultipart() override;
194 194
195 // Implementation of FormDataParser. 195 // Implementation of FormDataParser.
196 virtual bool AllDataReadOK() override; 196 bool AllDataReadOK() override;
197 virtual bool GetNextNameValue(Result* result) override; 197 bool GetNextNameValue(Result* result) override;
198 virtual bool SetSource(base::StringPiece source) override; 198 bool SetSource(base::StringPiece source) override;
199 199
200 private: 200 private:
201 enum State { 201 enum State {
202 STATE_INIT, // No input read yet. 202 STATE_INIT, // No input read yet.
203 STATE_READY, // Ready to call GetNextNameValue. 203 STATE_READY, // Ready to call GetNextNameValue.
204 STATE_FINISHED, // Read the input until the end. 204 STATE_FINISHED, // Read the input until the end.
205 STATE_SUSPEND, // Waiting until a new |source_| is set. 205 STATE_SUSPEND, // Waiting until a new |source_| is set.
206 STATE_ERROR 206 STATE_ERROR
207 }; 207 };
208 208
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 if (value_pattern().Match(header, 586 if (value_pattern().Match(header,
587 kContentDispositionLength, header.size(), 587 kContentDispositionLength, header.size(),
588 RE2::UNANCHORED, groups, 2)) { 588 RE2::UNANCHORED, groups, 2)) {
589 value->set(groups[1].data(), groups[1].size()); 589 value->set(groups[1].data(), groups[1].size());
590 *value_assigned = true; 590 *value_assigned = true;
591 } 591 }
592 return true; 592 return true;
593 } 593 }
594 594
595 } // namespace extensions 595 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/usb/usb_device_resource.h ('k') | extensions/browser/api/web_request/upload_data_presenter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698