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 #include "extensions/browser/api/web_request/upload_data_presenter.h" | 5 #include "extensions/browser/api/web_request/upload_data_presenter.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 return; | 118 return; |
119 } | 119 } |
120 if (!parser_->SetSource(base::StringPiece(bytes_reader->bytes(), | 120 if (!parser_->SetSource(base::StringPiece(bytes_reader->bytes(), |
121 bytes_reader->length()))) { | 121 bytes_reader->length()))) { |
122 Abort(); | 122 Abort(); |
123 return; | 123 return; |
124 } | 124 } |
125 | 125 |
126 FormDataParser::Result result; | 126 FormDataParser::Result result; |
127 while (parser_->GetNextNameValue(&result)) { | 127 while (parser_->GetNextNameValue(&result)) { |
128 GetOrCreateList(dictionary_.get(), result.name())->Append( | 128 GetOrCreateList(dictionary_.get(), result.name()) |
129 new base::StringValue(result.value())); | 129 ->AppendString(result.value()); |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 bool ParsedDataPresenter::Succeeded() { | 133 bool ParsedDataPresenter::Succeeded() { |
134 if (success_ && !parser_->AllDataReadOK()) | 134 if (success_ && !parser_->AllDataReadOK()) |
135 Abort(); | 135 Abort(); |
136 return success_; | 136 return success_; |
137 } | 137 } |
138 | 138 |
139 std::unique_ptr<base::Value> ParsedDataPresenter::Result() { | 139 std::unique_ptr<base::Value> ParsedDataPresenter::Result() { |
(...skipping 16 matching lines...) Expand all Loading... |
156 dictionary_(success_ ? new base::DictionaryValue() : NULL) { | 156 dictionary_(success_ ? new base::DictionaryValue() : NULL) { |
157 } | 157 } |
158 | 158 |
159 void ParsedDataPresenter::Abort() { | 159 void ParsedDataPresenter::Abort() { |
160 success_ = false; | 160 success_ = false; |
161 dictionary_.reset(); | 161 dictionary_.reset(); |
162 parser_.reset(); | 162 parser_.reset(); |
163 } | 163 } |
164 | 164 |
165 } // namespace extensions | 165 } // namespace extensions |
OLD | NEW |