OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "shell/crash/crash_upload.h" | 5 #include "shell/crash/crash_upload.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 last_modified_time = files.GetInfo().GetLastModifiedTime(); | 154 last_modified_time = files.GetInfo().GetLastModifiedTime(); |
155 } | 155 } |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 if (minidump.empty() || !CanUploadCrash(dumps_path)) | 159 if (minidump.empty() || !CanUploadCrash(dumps_path)) |
160 return MinidumpAndBoundary(); | 160 return MinidumpAndBoundary(); |
161 // Find multipart boundary. | 161 // Find multipart boundary. |
162 std::string start_of_file; | 162 std::string start_of_file; |
163 base::ReadFileToString(minidump, &start_of_file, kMaxBoundarySize); | 163 base::ReadFileToString(minidump, &start_of_file, kMaxBoundarySize); |
164 if (!StartsWithASCII(start_of_file, "--", true)) { | 164 if (!base::StartsWith(start_of_file, "--", base::CompareCase::SENSITIVE)) { |
165 LOG(WARNING) << "Corrupted minidump: " << minidump.value(); | 165 LOG(WARNING) << "Corrupted minidump: " << minidump.value(); |
166 base::DeleteFile(minidump, false); | 166 base::DeleteFile(minidump, false); |
167 return MinidumpAndBoundary(); | 167 return MinidumpAndBoundary(); |
168 } | 168 } |
169 size_t space_index = start_of_file.find_first_of(base::kWhitespaceASCII); | 169 size_t space_index = start_of_file.find_first_of(base::kWhitespaceASCII); |
170 if (space_index == std::string::npos || space_index <= 2) { | 170 if (space_index == std::string::npos || space_index <= 2) { |
171 // The boundary is either too big, or too short. | 171 // The boundary is either too big, or too short. |
172 LOG(WARNING) << "Corrupted minidump: " << minidump.value(); | 172 LOG(WARNING) << "Corrupted minidump: " << minidump.value(); |
173 base::DeleteFile(minidump, false); | 173 base::DeleteFile(minidump, false); |
174 return MinidumpAndBoundary(); | 174 return MinidumpAndBoundary(); |
175 } | 175 } |
176 return MinidumpAndBoundary(minidump, | 176 return MinidumpAndBoundary(minidump, |
177 start_of_file.substr(2, space_index - 2)); | 177 start_of_file.substr(2, space_index - 2)); |
178 } | 178 } |
179 | 179 |
180 } // namespace | 180 } // namespace |
181 | 181 |
182 void UploadCrashes(const base::FilePath& dumps_path, | 182 void UploadCrashes(const base::FilePath& dumps_path, |
183 scoped_refptr<base::TaskRunner> file_task_runner, | 183 scoped_refptr<base::TaskRunner> file_task_runner, |
184 mojo::NetworkServicePtr network_service) { | 184 mojo::NetworkServicePtr network_service) { |
185 base::PostTaskAndReplyWithResult( | 185 base::PostTaskAndReplyWithResult( |
186 file_task_runner.get(), FROM_HERE, | 186 file_task_runner.get(), FROM_HERE, |
187 base::Bind(&GetMinidumpAndBoundary, dumps_path), | 187 base::Bind(&GetMinidumpAndBoundary, dumps_path), |
188 base::Bind(&UploadCrash, file_task_runner, | 188 base::Bind(&UploadCrash, file_task_runner, |
189 base::Passed(network_service.Pass()), dumps_path)); | 189 base::Passed(network_service.Pass()), dumps_path)); |
190 } | 190 } |
191 | 191 |
192 } // namespace breakpad | 192 } // namespace breakpad |
OLD | NEW |