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

Side by Side Diff: chrome/browser/chromeos/boot_times_loader.cc

Issue 518843002: ChromeOS: Allow partial (uptime only) Uptime.Logout UMA metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/chromeos/boot_times_loader.h" 5 #include "chrome/browser/chromeos/boot_times_loader.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 Stats stats; 138 Stats stats;
139 // Callers of this method expect synchronous behavior. 139 // Callers of this method expect synchronous behavior.
140 // It's safe to allow IO here, because only virtual FS are accessed. 140 // It's safe to allow IO here, because only virtual FS are accessed.
141 base::ThreadRestrictions::ScopedAllowIO allow_io; 141 base::ThreadRestrictions::ScopedAllowIO allow_io;
142 base::ReadFileToString(kProcUptime, &stats.uptime_); 142 base::ReadFileToString(kProcUptime, &stats.uptime_);
143 base::ReadFileToString(kDiskStat, &stats.disk_); 143 base::ReadFileToString(kDiskStat, &stats.disk_);
144 return stats; 144 return stats;
145 } 145 }
146 146
147 std::string BootTimesLoader::Stats::SerializeToString() const { 147 std::string BootTimesLoader::Stats::SerializeToString() const {
148 if (uptime_.empty() || disk_.empty()) 148 if (uptime_.empty() && disk_.empty())
149 return std::string(); 149 return std::string();
150 base::DictionaryValue dictionary; 150 base::DictionaryValue dictionary;
151 dictionary.SetString(kUptime, uptime_); 151 dictionary.SetString(kUptime, uptime_);
152 dictionary.SetString(kDisk, disk_); 152 dictionary.SetString(kDisk, disk_);
153 153
154 std::string result; 154 std::string result;
155 if (!base::JSONWriter::Write(&dictionary, &result)) { 155 if (!base::JSONWriter::Write(&dictionary, &result)) {
156 LOG(WARNING) << "BootTimesLoader::Stats::SerializeToString(): failed."; 156 LOG(WARNING) << "BootTimesLoader::Stats::SerializeToString(): failed.";
157 return std::string(); 157 return std::string();
158 } 158 }
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 GetRenderWidgetHost(&web_contents->GetController()); 520 GetRenderWidgetHost(&web_contents->GetController());
521 render_widget_hosts_loading_.erase(render_widget_host); 521 render_widget_hosts_loading_.erase(render_widget_host);
522 break; 522 break;
523 } 523 }
524 default: 524 default:
525 break; 525 break;
526 } 526 }
527 } 527 }
528 528
529 } // namespace chromeos 529 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698