summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-12 12:00:40 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-12 12:00:40 +0000
commitd9eb3c45ead253d51ab8838055c5493ba0ac7951 (patch)
treebeab9a67d8fbd22a85301f784b48b8b55757ed60 /base
parentd4f06fa99aa8f04fedbb336fe4e115831b2bc6ca (diff)
downloadchromium_src-d9eb3c45ead253d51ab8838055c5493ba0ac7951.zip
chromium_src-d9eb3c45ead253d51ab8838055c5493ba0ac7951.tar.gz
chromium_src-d9eb3c45ead253d51ab8838055c5493ba0ac7951.tar.bz2
Port flush_cache tool and perf_tests.
BUG=4160,4263 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=6815 Review URL: http://codereview.chromium.org/9639 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6886 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/base_lib.scons2
-rw-r--r--base/test_file_util.h4
-rw-r--r--base/test_file_util_linux.cc5
-rw-r--r--base/test_file_util_mac.cc2
-rw-r--r--base/test_file_util_win.cc11
5 files changed, 14 insertions, 10 deletions
diff --git a/base/base_lib.scons b/base/base_lib.scons
index 8f8fd0c..50e7b99 100644
--- a/base/base_lib.scons
+++ b/base/base_lib.scons
@@ -191,6 +191,7 @@ if env['PLATFORM'] == 'darwin':
'platform_thread_mac.mm',
'scoped_nsautorelease_pool.mm',
'sys_string_conversions_mac.mm',
+ 'test_file_util_mac.cc',
'worker_pool_mac.mm',
])
@@ -207,6 +208,7 @@ if env['PLATFORM'] == 'posix':
'process_posix.cc',
'process_util_linux.cc',
'sys_string_conversions_linux.cc',
+ 'test_file_util_linux.cc',
'worker_pool.cc',
])
diff --git a/base/test_file_util.h b/base/test_file_util.h
index 3547d55..1ecaf29 100644
--- a/base/test_file_util.h
+++ b/base/test_file_util.h
@@ -9,11 +9,13 @@
#include <string>
+class FilePath;
+
namespace file_util {
// Clear a specific file from the system cache. After this call, trying
// to access this file will result in a cold load from the hard drive.
-bool EvictFileFromSystemCache(const wchar_t* file);
+bool EvictFileFromSystemCache(const FilePath& file);
// Like CopyFileNoCache but recursively copies all files and subdirectories
// in the given input directory to the output directory. Any files in the
diff --git a/base/test_file_util_linux.cc b/base/test_file_util_linux.cc
index 421d182..c1b3768 100644
--- a/base/test_file_util_linux.cc
+++ b/base/test_file_util_linux.cc
@@ -12,9 +12,8 @@
namespace file_util {
-bool EvictFileFromSystemCache(const wchar_t* file) {
- FilePath fpath = FilePath::FromWStringHack(file);
- int fd = open(fpath.value().c_str(), O_RDONLY);
+bool EvictFileFromSystemCache(const FilePath& file) {
+ int fd = open(file.value().c_str(), O_RDONLY);
if (fd < 0)
return false;
if (fdatasync(fd) != 0)
diff --git a/base/test_file_util_mac.cc b/base/test_file_util_mac.cc
index ebb13f3..1dd8533 100644
--- a/base/test_file_util_mac.cc
+++ b/base/test_file_util_mac.cc
@@ -8,7 +8,7 @@
namespace file_util {
-bool EvictFileFromSystemCache(const wchar_t* file) {
+bool EvictFileFromSystemCache(const FilePath& file) {
// TODO(port): Implement.
NOTIMPLEMENTED();
return false;
diff --git a/base/test_file_util_win.cc b/base/test_file_util_win.cc
index 6c4dc05..ba07c67 100644
--- a/base/test_file_util_win.cc
+++ b/base/test_file_util_win.cc
@@ -8,6 +8,7 @@
#include <vector>
+#include "base/file_path.h"
#include "base/file_util.h"
#include "base/scoped_handle.h"
@@ -17,10 +18,10 @@ namespace file_util {
// our purpose fine since 4K is the page size on x86 as well as x64.
static const ptrdiff_t kPageSize = 4096;
-bool EvictFileFromSystemCache(const wchar_t* file) {
+bool EvictFileFromSystemCache(const FilePath& file) {
// Request exclusive access to the file and overwrite it with no buffering.
ScopedHandle file_handle(
- CreateFile(file, GENERIC_READ | GENERIC_WRITE, 0, NULL,
+ CreateFile(file.value().c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL));
if (!file_handle)
return false;
@@ -85,8 +86,8 @@ bool EvictFileFromSystemCache(const wchar_t* file) {
// to open the file again, this time without the FILE_FLAG_NO_BUFFERING
// flag and use SetEndOfFile to mark EOF.
file_handle.Set(NULL);
- file_handle.Set(CreateFile(file, GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
- 0, NULL));
+ file_handle.Set(CreateFile(file.value().c_str(), GENERIC_WRITE, 0, NULL,
+ OPEN_EXISTING, 0, NULL));
CHECK(SetFilePointer(file_handle, total_bytes, NULL, FILE_BEGIN) !=
INVALID_SET_FILE_POINTER);
CHECK(::SetEndOfFile(file_handle));
@@ -147,7 +148,7 @@ bool CopyRecursiveDirNoCache(const std::wstring& source_dir,
// files that are in the repository, and they will have read-only set.
// This will prevent us from evicting from the cache, but these don't
// matter anyway.
- EvictFileFromSystemCache(cur_dest_path.c_str());
+ EvictFileFromSystemCache(FilePath::FromWStringHack(cur_dest_path));
}
} while (FindNextFile(fh, &fd));