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

Side by Side Diff: tools/perf/clear_system_cache/clear_system_cache_main.cc

Issue 819223002: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years 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 // A utility to clear the operating system's cache for a file or directory. 5 // A utility to clear the operating system's cache for a file or directory.
6 // 6 //
7 // USAGE: clear_system_cache [--recurse] <files or directories> 7 // USAGE: clear_system_cache [--recurse] <files or directories>
8 8
9 #include <stdio.h> 9 #include <stdio.h>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/files/file_enumerator.h" 13 #include "base/files/file_enumerator.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/test/test_file_util.h" 17 #include "base/test/test_file_util.h"
18 18
19 void ClearCacheForFile(const base::FilePath& path) { 19 void ClearCacheForFile(const base::FilePath& path) {
20 VLOG(1) << "Clearing " << path.MaybeAsASCII(); 20 VLOG(1) << "Clearing " << path.MaybeAsASCII();
21 base::EvictFileFromSystemCache(path); 21 base::EvictFileFromSystemCache(path);
22 } 22 }
23 23
24 int main(int argc, const char* argv[]) { 24 int main(int argc, const char* argv[]) {
25 CommandLine::Init(argc, argv); 25 base::CommandLine::Init(argc, argv);
26 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 26 const base::CommandLine& parsed_command_line =
27 *base::CommandLine::ForCurrentProcess();
27 bool should_recurse = parsed_command_line.HasSwitch("recurse"); 28 bool should_recurse = parsed_command_line.HasSwitch("recurse");
28 const CommandLine::StringVector& args = parsed_command_line.GetArgs(); 29 const base::CommandLine::StringVector& args = parsed_command_line.GetArgs();
29 30
30 if (args.size() < 1) { 31 if (args.size() < 1) {
31 printf("USAGE: %s [--recurse] <files or directories>\n", argv[0]); 32 printf("USAGE: %s [--recurse] <files or directories>\n", argv[0]);
32 return 1; 33 return 1;
33 } 34 }
34 35
35 for (size_t i = 0; i < args.size(); ++i) { 36 for (size_t i = 0; i < args.size(); ++i) {
36 base::FilePath path(args[i]); 37 base::FilePath path(args[i]);
37 if (!base::PathExists(path)) { 38 if (!base::PathExists(path)) {
38 LOG(ERROR) << "Couldn't find " << path.MaybeAsASCII(); 39 LOG(ERROR) << "Couldn't find " << path.MaybeAsASCII();
39 return 1; 40 return 1;
40 } 41 }
41 42
42 if (base::DirectoryExists(path)) { 43 if (base::DirectoryExists(path)) {
43 base::FileEnumerator enumerator(path, should_recurse, 44 base::FileEnumerator enumerator(path, should_recurse,
44 base::FileEnumerator::FILES); 45 base::FileEnumerator::FILES);
45 for (base::FilePath next = enumerator.Next(); !next.empty(); 46 for (base::FilePath next = enumerator.Next(); !next.empty();
46 next = enumerator.Next()) { 47 next = enumerator.Next()) {
47 ClearCacheForFile(next); 48 ClearCacheForFile(next);
48 } 49 }
49 } else { 50 } else {
50 ClearCacheForFile(path); 51 ClearCacheForFile(path);
51 } 52 }
52 } 53 }
53 54
54 return 0; 55 return 0;
55 } 56 }
OLDNEW
« no previous file with comments | « tools/ipc_fuzzer/replay/replay_process.cc ('k') | tools/set_default_handler/set_default_handler_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698