forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_pre_reader_win.h
35 lines (28 loc) · 1.57 KB
/
file_pre_reader_win.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file defines a function to pre-read a file in order to avoid touching
// the disk when it is subsequently used.
#ifndef CHROME_APP_FILE_PRE_READER_WIN_H_
#define CHROME_APP_FILE_PRE_READER_WIN_H_
namespace base {
class FilePath;
class MemoryMappedFile;
}
// Reads |file_path| to avoid touching the disk when the file is actually used.
// The function checks the Windows version to determine which pre-reading
// mechanism to use. On Vista+, chunks of 1 MB are read into a buffer. On XP,
// pre-reading non-PE files is not supported.
void PreReadFile(const base::FilePath& file_path);
// Returns true if the first page of |memory_mapped_file| is warm. This function
// must be called from a single-threaded process because it relies on the
// process-wide hard fault counter. Returns false on failure.
bool IsMemoryMappedFileWarm(const base::MemoryMappedFile& memory_mapped_file);
// Reads |memory_mapped_file| to avoid touching the disk when the mapped file is
// actually used. The function checks the Windows version to determine which
// pre-reading mechanism to use. On Win8+, it uses ::PrefetchVirtualMemory. On
// previous Windows versions, is uses PreReadFile (declared above). |file_path|
// is the path to the memory mapped file.
void PreReadMemoryMappedFile(const base::MemoryMappedFile& memory_mapped_file,
const base::FilePath& file_path);
#endif // CHROME_APP_FILE_PRE_READER_WIN_H_