| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/test/test_file_util.h" | 5 #include "base/test/test_file_util.h" |
| 6 | 6 |
| 7 #include <sys/mman.h> | 7 #include <sys/mman.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 | 9 |
| 10 #include "base/files/file_util.h" |
| 11 #include "base/files/memory_mapped_file.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/file_util.h" | |
| 12 #include "base/files/memory_mapped_file.h" | |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 | 15 |
| 16 bool EvictFileFromSystemCache(const FilePath& file) { | 16 bool EvictFileFromSystemCache(const FilePath& file) { |
| 17 // There aren't any really direct ways to purge a file from the UBC. From | 17 // There aren't any really direct ways to purge a file from the UBC. From |
| 18 // talking with Amit Singh, the safest is to mmap the file with MAP_FILE (the | 18 // talking with Amit Singh, the safest is to mmap the file with MAP_FILE (the |
| 19 // default) + MAP_SHARED, then do an msync to invalidate the memory. The next | 19 // default) + MAP_SHARED, then do an msync to invalidate the memory. The next |
| 20 // open should then have to load the file from disk. | 20 // open should then have to load the file from disk. |
| 21 | 21 |
| 22 int64 length; | 22 int64 length; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 42 MS_INVALIDATE) != 0) { | 42 MS_INVALIDATE) != 0) { |
| 43 DLOG(WARNING) << "failed to invalidate memory map of " << file.value() | 43 DLOG(WARNING) << "failed to invalidate memory map of " << file.value() |
| 44 << ", errno: " << errno; | 44 << ", errno: " << errno; |
| 45 return false; | 45 return false; |
| 46 } | 46 } |
| 47 | 47 |
| 48 return true; | 48 return true; |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace base | 51 } // namespace base |
| OLD | NEW |