| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file defines utility functions to pre-read a PE Image in order to | 5 // This file defines utility functions to pre-read a PE Image in order to |
| 6 // avoid hard page faults when the image is subsequently loaded into memory | 6 // avoid hard page faults when the image is subsequently loaded into memory |
| 7 // for execution. | 7 // for execution. |
| 8 | 8 |
| 9 #ifndef CHROME_APP_IMAGE_PRE_READER_WIN_H_ | 9 #ifndef CHROME_APP_IMAGE_PRE_READER_WIN_H_ |
| 10 #define CHROME_APP_IMAGE_PRE_READER_WIN_H_ | 10 #define CHROME_APP_IMAGE_PRE_READER_WIN_H_ |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // | 46 // |
| 47 // The max_chunk_size indicates the number of bytes to read off the disk in | 47 // The max_chunk_size indicates the number of bytes to read off the disk in |
| 48 // each step (for Vista and greater, where this is the way the pages are | 48 // each step (for Vista and greater, where this is the way the pages are |
| 49 // warmed). | 49 // warmed). |
| 50 // | 50 // |
| 51 // This function is intended to be used in the context of a PE image with | 51 // This function is intended to be used in the context of a PE image with |
| 52 // an optimized layout, such that the blocks in each section are arranged | 52 // an optimized layout, such that the blocks in each section are arranged |
| 53 // with the data and code most needed for startup moved to the front. | 53 // with the data and code most needed for startup moved to the front. |
| 54 // See also: http://code.google.com/p/chromium/issues/detail?id=98508 | 54 // See also: http://code.google.com/p/chromium/issues/detail?id=98508 |
| 55 static bool PartialPreReadImage(const wchar_t* file_path, | 55 static bool PartialPreReadImage(const wchar_t* file_path, |
| 56 uint8 percentage, | 56 size_t percentage, |
| 57 size_t max_chunk_size); | 57 size_t max_chunk_size); |
| 58 | 58 |
| 59 // Helper function used by PartialPreReadImage on Windows versions (Vista+) | 59 // Helper function used by PartialPreReadImage on Windows versions (Vista+) |
| 60 // where reading through the file on disk serves to warm up the page cache. | 60 // where reading through the file on disk serves to warm up the page cache. |
| 61 // Exported for unit-testing purposes. | 61 // Exported for unit-testing purposes. |
| 62 static bool PartialPreReadImageOnDisk(const wchar_t* file_path, | 62 static bool PartialPreReadImageOnDisk(const wchar_t* file_path, |
| 63 uint8 percentage, | 63 size_t percentage, |
| 64 size_t max_chunk_size); | 64 size_t max_chunk_size); |
| 65 | 65 |
| 66 // Helper function used by PartialPreReadImage on Windows versions (XP) where | 66 // Helper function used by PartialPreReadImage on Windows versions (XP) where |
| 67 // cheaply loading the image then stepping through its address space serves | 67 // cheaply loading the image then stepping through its address space serves |
| 68 // to warm up the page cache. Exported for unit-testing purposes. | 68 // to warm up the page cache. Exported for unit-testing purposes. |
| 69 static bool PartialPreReadImageInMemory(const wchar_t* file_path, | 69 static bool PartialPreReadImageInMemory(const wchar_t* file_path, |
| 70 uint8 percentage); | 70 size_t percentage); |
| 71 }; // namespace internal | 71 }; // namespace internal |
| 72 | 72 |
| 73 #endif // CHROME_APP_IMAGE_PRE_READER_WIN_H_ | 73 #endif // CHROME_APP_IMAGE_PRE_READER_WIN_H_ |
| OLD | NEW |