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

Side by Side Diff: base/test_file_util_mac.cc

Issue 42391: Add some UBC eviction code after talking to Amit (and it doesn't even require... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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_file_util.h" 5 #include "base/test_file_util.h"
6 6
7 #include <sys/mman.h>
Mark Mentovai 2009/03/19 14:50:07 Come on, what alphabet are we using today?
8 #include <errno.h>
7 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/file_util.h"
8 11
9 namespace file_util { 12 namespace file_util {
10 13
11 bool EvictFileFromSystemCache(const FilePath& file) { 14 bool EvictFileFromSystemCache(const FilePath& file) {
12 // There is no way that we can think of to dump something from the UBC. You 15 // There aren't any really direct ways to purge a file from the UBC. From
13 // can add something so when you open it, it doesn't go in, but that won't 16 // talking w/ Amit Singh, the safest is to mmap the file, do a msync to
Mark Mentovai 2009/03/19 14:50:07 I would do "an" msync unless you have a novel way
14 // work here. 17 // invalidate the memory. The next open should then have to load the
18 // file from disk.
19
20 // We use MemoryMappedFile because it mmaps MAP_FILE | MAP_SHARED (it doesn't
Mark Mentovai 2009/03/19 14:50:07 That's kind of obvious from reading MemoryMappedFi
21 // list MAP_FILE, but that's the default and it doesn't use MAP_ANON to avoid
22 // that default).
23
24 file_util::MemoryMappedFile mmap;
Mark Mentovai 2009/03/19 14:50:07 I would not name a variable mmap, mmap is the name
25 if (!mmap.Initialize(file)) {
26 DLOG(WARNING) << "failed to memory map " << file.value();
27 return false;
28 }
29
30 if (msync(const_cast<uint8*>(mmap.data()), mmap.length(),
31 MS_INVALIDATE) != 0) {
32 DLOG(WARNING) << "failed to invalidate memory map of " << file.value()
33 << ", errno: " << errno;
34 return false;
35 }
36
15 return true; 37 return true;
16 } 38 }
17 39
18 } // namespace file_util 40 } // namespace file_util
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698