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

Side by Side Diff: third_party/crashpad/crashpad/handler/crash_report_upload_thread.cc

Issue 2705373005: Revert of Update Crashpad to 6da9708e7cc93e2e1772439d51646e47583cb225 (Closed)
Patch Set: Created 3 years, 10 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 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 CrashReportDatabase* database_; // weak 132 CrashReportDatabase* database_; // weak
133 const CrashReportDatabase::Report* report_; // weak 133 const CrashReportDatabase::Report* report_; // weak
134 134
135 DISALLOW_COPY_AND_ASSIGN(CallRecordUploadAttempt); 135 DISALLOW_COPY_AND_ASSIGN(CallRecordUploadAttempt);
136 }; 136 };
137 137
138 } // namespace 138 } // namespace
139 139
140 CrashReportUploadThread::CrashReportUploadThread(CrashReportDatabase* database, 140 CrashReportUploadThread::CrashReportUploadThread(CrashReportDatabase* database,
141 const std::string& url, 141 const std::string& url,
142 bool rate_limit, 142 bool rate_limit)
143 bool upload_gzip)
144 : url_(url), 143 : url_(url),
145 // Check for pending reports every 15 minutes, even in the absence of a 144 // Check for pending reports every 15 minutes, even in the absence of a
146 // signal from the handler thread. This allows for failed uploads to be 145 // signal from the handler thread. This allows for failed uploads to be
147 // retried periodically, and for pending reports written by other 146 // retried periodically, and for pending reports written by other
148 // processes to be recognized. 147 // processes to be recognized.
149 thread_(15 * 60, this), 148 thread_(15 * 60, this),
150 database_(database), 149 database_(database),
151 rate_limit_(rate_limit), 150 rate_limit_(rate_limit) {
152 upload_gzip_(upload_gzip) {
153 } 151 }
154 152
155 CrashReportUploadThread::~CrashReportUploadThread() { 153 CrashReportUploadThread::~CrashReportUploadThread() {
156 } 154 }
157 155
158 void CrashReportUploadThread::Start() { 156 void CrashReportUploadThread::Start() {
159 thread_.Start(0); 157 thread_.Start(0);
160 } 158 }
161 159
162 void CrashReportUploadThread::Stop() { 160 void CrashReportUploadThread::Stop() {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 301 }
304 302
305 // If the minidump file could be opened, ignore any errors that might occur 303 // If the minidump file could be opened, ignore any errors that might occur
306 // when attempting to interpret it. This may result in its being uploaded 304 // when attempting to interpret it. This may result in its being uploaded
307 // with few or no parameters, but as long as there’s a dump file, the server 305 // with few or no parameters, but as long as there’s a dump file, the server
308 // can decide what to do with it. 306 // can decide what to do with it.
309 parameters = BreakpadHTTPFormParametersFromMinidump(&minidump_file_reader); 307 parameters = BreakpadHTTPFormParametersFromMinidump(&minidump_file_reader);
310 } 308 }
311 309
312 HTTPMultipartBuilder http_multipart_builder; 310 HTTPMultipartBuilder http_multipart_builder;
313 http_multipart_builder.SetGzipEnabled(upload_gzip_);
314 311
315 const char kMinidumpKey[] = "upload_file_minidump"; 312 const char kMinidumpKey[] = "upload_file_minidump";
316 313
317 for (const auto& kv : parameters) { 314 for (const auto& kv : parameters) {
318 if (kv.first == kMinidumpKey) { 315 if (kv.first == kMinidumpKey) {
319 LOG(WARNING) << "reserved key " << kv.first << ", discarding value " 316 LOG(WARNING) << "reserved key " << kv.first << ", discarding value "
320 << kv.second; 317 << kv.second;
321 } else { 318 } else {
322 http_multipart_builder.SetFormData(kv.first, kv.second); 319 http_multipart_builder.SetFormData(kv.first, kv.second);
323 } 320 }
324 } 321 }
325 322
326 http_multipart_builder.SetFileAttachment( 323 http_multipart_builder.SetFileAttachment(
327 kMinidumpKey, 324 kMinidumpKey,
328 #if defined(OS_WIN) 325 #if defined(OS_WIN)
329 base::UTF16ToUTF8(report->file_path.BaseName().value()), 326 base::UTF16ToUTF8(report->file_path.BaseName().value()),
330 #else 327 #else
331 report->file_path.BaseName().value(), 328 report->file_path.BaseName().value(),
332 #endif 329 #endif
333 report->file_path, 330 report->file_path,
334 "application/octet-stream"); 331 "application/octet-stream");
335 332
336 std::unique_ptr<HTTPTransport> http_transport(HTTPTransport::Create()); 333 std::unique_ptr<HTTPTransport> http_transport(HTTPTransport::Create());
337 http_transport->SetURL(url_); 334 http_transport->SetURL(url_);
338 HTTPHeaders content_headers; 335 HTTPHeaders::value_type content_type =
339 http_multipart_builder.PopulateContentHeaders(&content_headers); 336 http_multipart_builder.GetContentType();
340 for (const auto& content_header : content_headers) { 337 http_transport->SetHeader(content_type.first, content_type.second);
341 http_transport->SetHeader(content_header.first, content_header.second);
342 }
343 http_transport->SetBodyStream(http_multipart_builder.GetBodyStream()); 338 http_transport->SetBodyStream(http_multipart_builder.GetBodyStream());
344 // TODO(mark): The timeout should be configurable by the client. 339 // TODO(mark): The timeout should be configurable by the client.
345 http_transport->SetTimeout(60.0); // 1 minute. 340 http_transport->SetTimeout(60.0); // 1 minute.
346 341
347 if (!http_transport->ExecuteSynchronously(response_body)) { 342 if (!http_transport->ExecuteSynchronously(response_body)) {
348 return UploadResult::kRetry; 343 return UploadResult::kRetry;
349 } 344 }
350 345
351 return UploadResult::kSuccess; 346 return UploadResult::kSuccess;
352 } 347 }
353 348
354 void CrashReportUploadThread::DoWork(const WorkerThread* thread) { 349 void CrashReportUploadThread::DoWork(const WorkerThread* thread) {
355 ProcessPendingReports(); 350 ProcessPendingReports();
356 } 351 }
357 352
358 } // namespace crashpad 353 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698