Chromium Code Reviews| Index: chrome/app/file_pre_reader_win.cc |
| diff --git a/chrome/app/file_pre_reader_win.cc b/chrome/app/file_pre_reader_win.cc |
| index f95c0276b5dbff0ff4b1e5ace5e6015842ef31b4..29c90e1256866ec85ad313e139d4a1557e56f247 100644 |
| --- a/chrome/app/file_pre_reader_win.cc |
| +++ b/chrome/app/file_pre_reader_win.cc |
| @@ -7,16 +7,8 @@ |
| #include <windows.h> |
| #include "base/files/file.h" |
| -#include "base/files/memory_mapped_file.h" |
| -#include "base/logging.h" |
| -#include "base/threading/platform_thread.h" |
| -#include "base/threading/thread_restrictions.h" |
| -#include "components/startup_metric_utils/common/pre_read_field_trial_utils_win.h" |
| -namespace { |
| - |
| -// Pre-reads |file_path| using ::ReadFile. |
| -void PreReadFileUsingReadFile(const base::FilePath& file_path) { |
| +void PreReadFile(const base::FilePath& file_path) { |
| base::File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ | |
| base::File::FLAG_SEQUENTIAL_SCAN); |
| if (!file.IsValid()) |
| @@ -32,62 +24,3 @@ void PreReadFileUsingReadFile(const base::FilePath& file_path) { |
| ::VirtualFree(buffer, 0, MEM_RELEASE); |
| } |
| - |
| -// Pre-reads |file_path| using ::PrefetchVirtualMemory, if available. Otherwise, |
| -// falls back on using ::ReadFile. |
| -void PreReadFileUsingPrefetchVirtualMemory(const base::FilePath& file_path) { |
| - // Load ::PrefetchVirtualMemory dynamically, because it is only available on |
| - // Win8+. |
| - using PrefetchVirtualMemoryPtr = decltype(::PrefetchVirtualMemory)*; |
| - PrefetchVirtualMemoryPtr prefetch_virtual_memory = |
| - reinterpret_cast<PrefetchVirtualMemoryPtr>(::GetProcAddress( |
| - ::GetModuleHandle(L"kernel32.dll"), "PrefetchVirtualMemory")); |
|
gab
2016/08/31 16:39:57
Interesting, so the built-in Windows prefetcher wa
fdoray
2016/08/31 19:50:52
From ETW traces, it looks like PrefetchVirtualMemo
gab
2016/08/31 19:54:47
Ok, then I'd say add a comment mentioning that thi
fdoray
2016/08/31 20:00:33
Done.
|
| - if (!prefetch_virtual_memory) { |
| - // If ::PrefetchVirtualMemory is not available, fall back to |
| - // PreReadFileUsingReadFile(). |
| - PreReadFileUsingReadFile(file_path); |
| - return; |
| - } |
| - |
| - base::MemoryMappedFile memory_mapped_file; |
| - if (!memory_mapped_file.Initialize(file_path)) { |
| - // Initializing the memory map should not fail. If it does fail in a debug |
| - // build, we want to be warned about it so that we can investigate the |
| - // failure. |
| - NOTREACHED(); |
| - PreReadFileUsingReadFile(file_path); |
| - return; |
| - } |
| - |
| - WIN32_MEMORY_RANGE_ENTRY memory_range; |
| - memory_range.VirtualAddress = const_cast<void*>( |
| - reinterpret_cast<const void*>(memory_mapped_file.data())); |
| - memory_range.NumberOfBytes = memory_mapped_file.length(); |
| - prefetch_virtual_memory(::GetCurrentProcess(), 1U, &memory_range, 0); |
| -} |
| - |
| -} // namespace |
| - |
| -void PreReadFile(const base::FilePath& file_path, |
| - const startup_metric_utils::PreReadOptions& pre_read_options) { |
| - DCHECK(pre_read_options.pre_read); |
| - base::ThreadRestrictions::AssertIOAllowed(); |
| - |
| - // Increase thread priority if necessary. |
| - base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL; |
| - if (pre_read_options.high_priority) { |
| - previous_priority = base::PlatformThread::GetCurrentThreadPriority(); |
| - base::PlatformThread::SetCurrentThreadPriority( |
| - base::ThreadPriority::DISPLAY); |
| - } |
| - |
| - // Pre-read |file_path|. |
| - if (pre_read_options.prefetch_virtual_memory) |
| - PreReadFileUsingPrefetchVirtualMemory(file_path); |
| - else |
| - PreReadFileUsingReadFile(file_path); |
| - |
| - // Reset thread priority. |
| - if (pre_read_options.high_priority) |
| - base::PlatformThread::SetCurrentThreadPriority(previous_priority); |
| -} |