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

Unified Diff: chrome/browser/ui/webui/media/webrtc_logs_ui.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/flash_ui.cc ('k') | components/crash/core/browser/crashes_ui_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/media/webrtc_logs_ui.cc
diff --git a/chrome/browser/ui/webui/media/webrtc_logs_ui.cc b/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
index 37ab6fe51bbe42a3d425011c20c71c08df84d05d..fab1fbe2b9093aa6516a7de8da56eee91d26b343 100644
--- a/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
+++ b/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
@@ -11,6 +11,7 @@
#include "base/i18n/time_formatting.h"
#include "base/memory/ref_counted_memory.h"
#include "base/prefs/pref_service.h"
+#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -148,29 +149,50 @@ void WebRtcLogsDOMHandler::UpdateUI() {
for (std::vector<UploadList::UploadInfo>::iterator i = uploads.begin();
i != uploads.end();
++i) {
- base::DictionaryValue* upload = new base::DictionaryValue();
- upload->SetString("id", i->id);
+ scoped_ptr<base::DictionaryValue> upload(new base::DictionaryValue());
+ upload->SetString("id", i->upload_id);
base::string16 value_w;
- if (!i->time.is_null())
- value_w = base::TimeFormatFriendlyDateAndTime(i->time);
+ if (!i->upload_time.is_null())
+ value_w = base::TimeFormatFriendlyDateAndTime(i->upload_time);
upload->SetString("upload_time", value_w);
- value_w.clear();
- double seconds_since_epoch;
- if (base::StringToDouble(i->local_id, &seconds_since_epoch)) {
- base::Time capture_time = base::Time::FromDoubleT(seconds_since_epoch);
- value_w = base::TimeFormatFriendlyDateAndTime(capture_time);
- }
- upload->SetString("capture_time", value_w);
-
base::FilePath::StringType value;
if (!i->local_id.empty())
value = log_dir_.AppendASCII(i->local_id)
.AddExtension(FILE_PATH_LITERAL(".gz")).value();
upload->SetString("local_file", value);
- upload_list.Append(upload);
+ // In october 2015, capture time was added to the log list, previously the
+ // local ID was used as capture time. The local ID has however changed so
+ // that it might not be a time. We fall back on the local ID if it traslates
+ // to a time within reasonable bounds, otherwise we fall back on the upload
+ // time.
+ // TODO(grunell): Use |capture_time| only.
+ if (!i->capture_time.is_null()) {
+ value_w = base::TimeFormatFriendlyDateAndTime(i->capture_time);
+ } else {
+ // Fall back on local ID as time. We need to check that it's within
+ // resonable bounds, since the ID may not represent time. Check between
+ // 2012 when the feature was introduced and now.
+ double seconds_since_epoch;
+ if (base::StringToDouble(i->local_id, &seconds_since_epoch)) {
+ base::Time capture_time = base::Time::FromDoubleT(seconds_since_epoch);
+ base::Time::Exploded lower_limit = {2012, 1, 0, 1, 0, 0, 0, 0};
+ if (capture_time > base::Time::FromUTCExploded(lower_limit) &&
+ capture_time < base::Time::Now()) {
+ value_w = base::TimeFormatFriendlyDateAndTime(capture_time);
+ }
+ }
+ }
+ // If we haven't set |value_w| above, we fall back on the upload time, which
+ // was already in the variable. In case it's empty set the string to
+ // inform that the time is unknown.
+ if (value_w.empty())
+ value_w = base::string16(base::ASCIIToUTF16("(unknown time)"));
+ upload->SetString("capture_time", value_w);
+
+ upload_list.Append(upload.Pass());
}
base::StringValue version(version_info::GetVersionNumber());
« no previous file with comments | « chrome/browser/ui/webui/flash_ui.cc ('k') | components/crash/core/browser/crashes_ui_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698