- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / tools / perf / flush_cache / flush_cache.cc
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This little program attempts to flush the system cache for some files.
6 // It's useful for testing Chrome with a cold database.
7
8 #include "base/files/file_path.h"
9 #include "base/process/memory.h"
10 #include "base/test/test_file_util.h"
11
12 int main(int argc, const char* argv[]) {
13   base::EnableTerminationOnHeapCorruption();
14   if (argc <= 1) {
15     fprintf(stderr, "flushes disk cache for files\n");
16     fprintf(stderr, "usage: %s <filenames>\n", argv[0]);
17     return 1;
18   }
19
20   for (int i = 1; i < argc; ++i) {
21     base::FilePath path = base::FilePath::FromUTF8Unsafe(argv[i]);
22     if (!file_util::EvictFileFromSystemCache(path)) {
23       fprintf(stderr, "Failed to evict %s from cache -- is it a directory?\n",
24               argv[i]);
25     }
26   }
27
28   return 0;
29 }