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 contains utility functions for dealing with the local | 5 // This file contains utility functions for dealing with the local |
6 // filesystem. | 6 // filesystem. |
7 | 7 |
8 #ifndef BASE_FILE_UTIL_H_ | 8 #ifndef BASE_FILE_UTIL_H_ |
9 #define BASE_FILE_UTIL_H_ | 9 #define BASE_FILE_UTIL_H_ |
10 #pragma once | 10 #pragma once |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
602 | 602 |
603 DISALLOW_COPY_AND_ASSIGN(MemoryMappedFile); | 603 DISALLOW_COPY_AND_ASSIGN(MemoryMappedFile); |
604 }; | 604 }; |
605 | 605 |
606 // Returns whether the file has been modified since a particular date. | 606 // Returns whether the file has been modified since a particular date. |
607 BASE_EXPORT bool HasFileBeenModifiedSince( | 607 BASE_EXPORT bool HasFileBeenModifiedSince( |
608 const FileEnumerator::FindInfo& find_info, | 608 const FileEnumerator::FindInfo& find_info, |
609 const base::Time& cutoff_time); | 609 const base::Time& cutoff_time); |
610 | 610 |
611 #if defined(OS_WIN) | 611 #if defined(OS_WIN) |
612 // Loads the file passed in as an image section and touches pages to avoid | 612 // Loads the file passed in as an image section and touches pages to avoid |
613 // subsequent hard page faults during LoadLibrary. The size to be pre read | 613 // subsequent hard page faults during LoadLibrary. The size to be pre read |
614 // is passed in. If it is 0 then the whole file is paged in. The step size | 614 // is passed in. If it is 0 then the whole file is paged in. The step size |
615 // which indicates the number of bytes to skip after every page touched is | 615 // which indicates the number of bytes to skip after every page touched is |
616 // also passed in. | 616 // also passed in. |
617 bool BASE_EXPORT PreReadImage(const wchar_t* file_path, size_t size_to_read, | 617 bool BASE_EXPORT PreReadImage(const wchar_t* file_path, size_t size_to_read, |
618 size_t step_size); | 618 size_t step_size); |
619 | |
620 // Loads the file passed in as an image section and touches pages to avoid | |
621 // subsequent hard page faults during LoadLibrary. The percentage of the | |
622 // file to be read is passed in, as an integral value between 0 and 100, | |
623 // inclusive. If it is 0 then this is a NOP, if it is 100 (or greater) then | |
624 // the whole file is paged in via PreReadImage. The max_chunk_size, which | |
Evan Martin
2012/01/27 20:13:58
This isn't clear to me -- does a percentage of 50
Roger McFarlane (Google)
2012/01/27 21:25:54
Clarified the comments, and switched percentage to
| |
625 // indicates the number of bytes to read off the disk in each step (for | |
626 // operating systems where this is the way the pages are warmed), is also | |
627 // passed in (otherwise, the in-memory image is touched once per system page). | |
628 bool BASE_EXPORT PartialPreReadImage(const wchar_t* file_path, | |
Evan Martin
2012/01/27 20:13:58
Everywhere else I think we put BASE_EXPORT first.
Roger McFarlane (Google)
2012/01/27 21:25:54
Done.
| |
629 size_t percentage, | |
630 size_t max_chunk_size); | |
631 namespace internal { | |
632 | |
633 // Helper function used by PartialPreReadImage on Windows versions (Vista+) | |
634 // where reading through the file on disk serves to warm up the page cache. | |
635 // Exported for unit-testing purposes. | |
636 bool BASE_EXPORT PartialPreReadImageOnDisk(const wchar_t* file_path, | |
637 size_t percentage, | |
638 size_t max_chunk_size); | |
639 | |
640 // Helper function used by PartialPreReadImage on Windows versions (XP) where | |
641 // cheaply loading the image then stepping through its address space serves | |
642 // to warm up the page cache. Exported for unit-testing purposes. | |
643 bool BASE_EXPORT PartialPreReadImageInMemory(const wchar_t* file_path, | |
644 size_t percentage); | |
645 | |
646 } // namespace internal | |
647 | |
619 #endif // OS_WIN | 648 #endif // OS_WIN |
620 | 649 |
621 #if defined(OS_LINUX) | 650 #if defined(OS_LINUX) |
622 // Broad categories of file systems as returned by statfs() on Linux. | 651 // Broad categories of file systems as returned by statfs() on Linux. |
623 enum FileSystemType { | 652 enum FileSystemType { |
624 FILE_SYSTEM_UNKNOWN, // statfs failed. | 653 FILE_SYSTEM_UNKNOWN, // statfs failed. |
625 FILE_SYSTEM_0, // statfs.f_type == 0 means unknown, may indicate AFS. | 654 FILE_SYSTEM_0, // statfs.f_type == 0 means unknown, may indicate AFS. |
626 FILE_SYSTEM_ORDINARY, // on-disk filesystem like ext2 | 655 FILE_SYSTEM_ORDINARY, // on-disk filesystem like ext2 |
627 FILE_SYSTEM_NFS, | 656 FILE_SYSTEM_NFS, |
628 FILE_SYSTEM_SMB, | 657 FILE_SYSTEM_SMB, |
629 FILE_SYSTEM_CODA, | 658 FILE_SYSTEM_CODA, |
630 FILE_SYSTEM_MEMORY, // in-memory file system | 659 FILE_SYSTEM_MEMORY, // in-memory file system |
631 FILE_SYSTEM_CGROUP, // cgroup control. | 660 FILE_SYSTEM_CGROUP, // cgroup control. |
632 FILE_SYSTEM_OTHER, // any other value. | 661 FILE_SYSTEM_OTHER, // any other value. |
633 FILE_SYSTEM_TYPE_COUNT | 662 FILE_SYSTEM_TYPE_COUNT |
634 }; | 663 }; |
635 | 664 |
636 // Attempts determine the FileSystemType for |path|. | 665 // Attempts determine the FileSystemType for |path|. |
637 // Returns false if |path| doesn't exist. | 666 // Returns false if |path| doesn't exist. |
638 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); | 667 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); |
639 #endif | 668 #endif |
640 | 669 |
641 } // namespace file_util | 670 } // namespace file_util |
642 | 671 |
643 // Deprecated functions have been moved to this separate header file, | 672 // Deprecated functions have been moved to this separate header file, |
644 // which must be included last after all the above definitions. | 673 // which must be included last after all the above definitions. |
645 #include "base/file_util_deprecated.h" | 674 #include "base/file_util_deprecated.h" |
646 | 675 |
647 #endif // BASE_FILE_UTIL_H_ | 676 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |