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

Side by Side Diff: chrome/browser/media/webrtc_log_uploader.cc

Issue 1405373002: Fix WebRTC log list errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/media/webrtc_log_uploader.h" 5 #include "chrome/browser/media/webrtc_log_uploader.h"
6 6
7 #include "base/files/file_enumerator.h" 7 #include "base/files/file_enumerator.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 if (contents[i] == '\n') 494 if (contents[i] == '\n')
495 ++lf_count; 495 ++lf_count;
496 } 496 }
497 if (lf_count >= kLogListLimitLines) { 497 if (lf_count >= kLogListLimitLines) {
498 // + 1 to compensate for the for loop decrease before the conditional 498 // + 1 to compensate for the for loop decrease before the conditional
499 // check and + 1 to get the length. 499 // check and + 1 to get the length.
500 contents.erase(0, i + 2); 500 contents.erase(0, i + 2);
501 } 501 }
502 } 502 }
503 503
504 // Write the log ID to the log list file. Leave the upload time and report ID 504 // Write the capture time and log ID to the log list file. Leave the upload
505 // empty. 505 // time and report ID empty.
506 contents += ",," + local_log_id + '\n'; 506 contents += ",," + local_log_id +
507 "," + base::DoubleToString(base::Time::Now().ToDoubleT()) + '\n';
507 508
508 int written = 509 int written =
509 base::WriteFile(upload_list_path, &contents[0], contents.size()); 510 base::WriteFile(upload_list_path, &contents[0], contents.size());
510 if (written != static_cast<int>(contents.size())) { 511 if (written != static_cast<int>(contents.size())) {
511 DPLOG(WARNING) << "Could not write all data to WebRTC log list file: " 512 DPLOG(WARNING) << "Could not write all data to WebRTC log list file: "
512 << written; 513 << written;
513 } 514 }
514 } 515 }
515 516
516 void WebRtcLogUploader::AddUploadedLogInfoToUploadListFile( 517 void WebRtcLogUploader::AddUploadedLogInfoToUploadListFile(
(...skipping 17 matching lines...) Expand all
534 // Write the Unix time and report ID to the log list file. We should be able 535 // Write the Unix time and report ID to the log list file. We should be able
535 // to find the local log ID, in that case insert the data into the existing 536 // to find the local log ID, in that case insert the data into the existing
536 // line. Otherwise add it in the end. 537 // line. Otherwise add it in the end.
537 base::Time time_now = base::Time::Now(); 538 base::Time time_now = base::Time::Now();
538 std::string time_now_str = base::DoubleToString(time_now.ToDoubleT()); 539 std::string time_now_str = base::DoubleToString(time_now.ToDoubleT());
539 size_t pos = contents.find(",," + local_log_id); 540 size_t pos = contents.find(",," + local_log_id);
540 if (pos != std::string::npos) { 541 if (pos != std::string::npos) {
541 contents.insert(pos, time_now_str); 542 contents.insert(pos, time_now_str);
542 contents.insert(pos + time_now_str.length() + 1, report_id); 543 contents.insert(pos + time_now_str.length() + 1, report_id);
543 } else { 544 } else {
544 contents += time_now_str + "," + report_id + ",\n"; 545 contents += time_now_str + "," + report_id + ",," + time_now_str + "\n";
545 } 546 }
546 547
547 int written = 548 int written =
548 base::WriteFile(upload_list_path, &contents[0], contents.size()); 549 base::WriteFile(upload_list_path, &contents[0], contents.size());
549 if (written != static_cast<int>(contents.size())) { 550 if (written != static_cast<int>(contents.size())) {
550 DPLOG(WARNING) << "Could not write all data to WebRTC log list file: " 551 DPLOG(WARNING) << "Could not write all data to WebRTC log list file: "
551 << written; 552 << written;
552 } 553 }
553 } 554 }
554 555
(...skipping 10 matching lines...) Expand all
565 if (!success) { 566 if (!success) {
566 error_message = "Uploading failed, response code: " + 567 error_message = "Uploading failed, response code: " +
567 base::IntToString(response_code); 568 base::IntToString(response_code);
568 } 569 }
569 content::BrowserThread::PostTask( 570 content::BrowserThread::PostTask(
570 content::BrowserThread::UI, FROM_HERE, 571 content::BrowserThread::UI, FROM_HERE,
571 base::Bind(upload_done_data.callback, success, report_id, 572 base::Bind(upload_done_data.callback, success, report_id,
572 error_message)); 573 error_message));
573 } 574 }
574 } 575 }
OLDNEW
« no previous file with comments | « chrome/browser/crash_upload_list_mac.cc ('k') | chrome/browser/media/webrtc_log_uploader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698