OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |