| OLD | NEW |
| 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 #ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_FORM_DATA_PARSER_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_FORM_DATA_PARSER_H_ |
| 6 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_FORM_DATA_PARSER_H_ | 6 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_FORM_DATA_PARSER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 // Cannot forward declare StringPiece because it is a typedef. | 12 // Cannot forward declare StringPiece because it is a typedef. |
| 13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 class URLRequest; | 16 class URLRequest; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace extensions { | 19 namespace extensions { |
| 20 | 20 |
| 21 // Interface for the form data parsers. | 21 // Interface for the form data parsers. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 37 std::string name_; | 37 std::string name_; |
| 38 std::string value_; | 38 std::string value_; |
| 39 | 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(Result); | 40 DISALLOW_COPY_AND_ASSIGN(Result); |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 virtual ~FormDataParser(); | 43 virtual ~FormDataParser(); |
| 44 | 44 |
| 45 // Creates a correct parser instance based on the |request|. Returns NULL | 45 // Creates a correct parser instance based on the |request|. Returns NULL |
| 46 // on failure. | 46 // on failure. |
| 47 static scoped_ptr<FormDataParser> Create(const net::URLRequest& request); | 47 static std::unique_ptr<FormDataParser> Create(const net::URLRequest& request); |
| 48 | 48 |
| 49 // Creates a correct parser instance based on |content_type_header|, the | 49 // Creates a correct parser instance based on |content_type_header|, the |
| 50 // "Content-Type" request header value. If |content_type_header| is NULL, it | 50 // "Content-Type" request header value. If |content_type_header| is NULL, it |
| 51 // defaults to "application/x-www-form-urlencoded". Returns NULL on failure. | 51 // defaults to "application/x-www-form-urlencoded". Returns NULL on failure. |
| 52 static scoped_ptr<FormDataParser> CreateFromContentTypeHeader( | 52 static std::unique_ptr<FormDataParser> CreateFromContentTypeHeader( |
| 53 const std::string* content_type_header); | 53 const std::string* content_type_header); |
| 54 | 54 |
| 55 // Returns true if there was some data, it was well formed and all was read. | 55 // Returns true if there was some data, it was well formed and all was read. |
| 56 virtual bool AllDataReadOK() = 0; | 56 virtual bool AllDataReadOK() = 0; |
| 57 | 57 |
| 58 // Gets the next name-value pair from the source data and stores it in | 58 // Gets the next name-value pair from the source data and stores it in |
| 59 // |result|. Returns true if a pair was found. Callers must have previously | 59 // |result|. Returns true if a pair was found. Callers must have previously |
| 60 // succesfully called the SetSource method. | 60 // succesfully called the SetSource method. |
| 61 virtual bool GetNextNameValue(Result* result) = 0; | 61 virtual bool GetNextNameValue(Result* result) = 0; |
| 62 | 62 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 73 protected: | 73 protected: |
| 74 FormDataParser(); | 74 FormDataParser(); |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 DISALLOW_COPY_AND_ASSIGN(FormDataParser); | 77 DISALLOW_COPY_AND_ASSIGN(FormDataParser); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace extensions | 80 } // namespace extensions |
| 81 | 81 |
| 82 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_FORM_DATA_PARSER_H_ | 82 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_FORM_DATA_PARSER_H_ |
| OLD | NEW |