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

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

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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/chromeos/swap_metrics.h" 5 #include "chrome/browser/chromeos/swap_metrics.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 counter->Add(cpu); 254 counter->Add(cpu);
255 } 255 }
256 256
257 // Extracts a field value from a list of name-value pairs 257 // Extracts a field value from a list of name-value pairs
258 // in a file (typically a /proc or /sys file). Returns false 258 // in a file (typically a /proc or /sys file). Returns false
259 // if the field is not found, or for other errors. 259 // if the field is not found, or for other errors.
260 bool SwapMetrics::Backend::GetFieldFromKernelOutput(const std::string& path, 260 bool SwapMetrics::Backend::GetFieldFromKernelOutput(const std::string& path,
261 const std::string& field, 261 const std::string& field,
262 int64* value) { 262 int64* value) {
263 std::string file_content; 263 std::string file_content;
264 if (!file_util::ReadFileToString(FilePath(path), &file_content)) { 264 if (!base::ReadFileToString(FilePath(path), &file_content)) {
265 LOG(WARNING) << "Cannot read " << path; 265 LOG(WARNING) << "Cannot read " << path;
266 return false; 266 return false;
267 } 267 }
268 std::vector<std::string> lines; 268 std::vector<std::string> lines;
269 size_t line_count = Tokenize(file_content, "\n", &lines); 269 size_t line_count = Tokenize(file_content, "\n", &lines);
270 if (line_count < 2) { 270 if (line_count < 2) {
271 LOG(WARNING) << "Error breaking " << path << " into lines"; 271 LOG(WARNING) << "Error breaking " << path << " into lines";
272 return false; 272 return false;
273 } 273 }
274 for (size_t i = 0; i < line_count; ++i) { 274 for (size_t i = 0; i < line_count; ++i) {
(...skipping 14 matching lines...) Expand all
289 LOG(WARNING) << "could not find field " << field; 289 LOG(WARNING) << "could not find field " << field;
290 return false; 290 return false;
291 } 291 }
292 292
293 bool SwapMetrics::Backend::TokenizeOneLineFile(const std::string& path, 293 bool SwapMetrics::Backend::TokenizeOneLineFile(const std::string& path,
294 size_t expected_tokens_count, 294 size_t expected_tokens_count,
295 const std::string& delimiters, 295 const std::string& delimiters,
296 std::vector<std::string>* 296 std::vector<std::string>*
297 tokens) { 297 tokens) {
298 std::string file_content; 298 std::string file_content;
299 if (!file_util::ReadFileToString(FilePath(path), &file_content)) { 299 if (!base::ReadFileToString(FilePath(path), &file_content)) {
300 LOG(WARNING) << "cannot read " << path; 300 LOG(WARNING) << "cannot read " << path;
301 return false; 301 return false;
302 } 302 }
303 size_t tokens_count = Tokenize(file_content, delimiters, tokens); 303 size_t tokens_count = Tokenize(file_content, delimiters, tokens);
304 if (tokens_count != expected_tokens_count) { 304 if (tokens_count != expected_tokens_count) {
305 LOG(WARNING) << "unexpected content of " << path << ": " << file_content; 305 LOG(WARNING) << "unexpected content of " << path << ": " << file_content;
306 return false; 306 return false;
307 } 307 }
308 return true; 308 return true;
309 } 309 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 if (browser_ == browser) 423 if (browser_ == browser)
424 return; 424 return;
425 if (browser_) 425 if (browser_)
426 browser_->tab_strip_model()->RemoveObserver(this); 426 browser_->tab_strip_model()->RemoveObserver(this);
427 browser_ = browser; 427 browser_ = browser;
428 if (browser_) 428 if (browser_)
429 browser_->tab_strip_model()->AddObserver(this); 429 browser_->tab_strip_model()->AddObserver(this);
430 } 430 }
431 431
432 } // namespace chromeos 432 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698