OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_INSTALLER_UTIL_LZMA_FILE_ALLOCATOR_H_ | 5 #ifndef CHROME_INSTALLER_UTIL_LZMA_FILE_ALLOCATOR_H_ |
6 #define CHROME_INSTALLER_UTIL_LZMA_FILE_ALLOCATOR_H_ | 6 #define CHROME_INSTALLER_UTIL_LZMA_FILE_ALLOCATOR_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/win/scoped_handle.h" | 14 #include "base/win/scoped_handle.h" |
15 | 15 #include "third_party/lzma_sdk/7zTypes.h" |
16 extern "C" { | |
17 #include "third_party/lzma_sdk/Types.h" | |
18 } | |
19 | 16 |
20 // File mapping memory management class which supports multiple allocations in | 17 // File mapping memory management class which supports multiple allocations in |
21 // series, but not in parallel. It creates a unique temporary file within | 18 // series, but not in parallel. It creates a unique temporary file within |
22 // |temp_directory| to back subsequent allocations and falls back to normal | 19 // |temp_directory| to back subsequent allocations and falls back to normal |
23 // management in case of error. | 20 // management in case of error. |
24 // Example: | 21 // Example: |
25 // LzmaFileAllocator allocator(mmp_file_path); | 22 // LzmaFileAllocator allocator(mmp_file_path); |
26 // char* s = reinterpret_cast<char*>(IAlloc_Alloc(&allocator, size)); | 23 // char* s = reinterpret_cast<char*>(IAlloc_Alloc(&allocator, size)); |
27 // IAlloc_Free(&allocator, s); | 24 // IAlloc_Free(&allocator, s); |
28 class LzmaFileAllocator : public ISzAlloc { | 25 class LzmaFileAllocator : public ISzAlloc { |
(...skipping 17 matching lines...) Expand all Loading... |
46 static void SzFileFree(void* p, void* address); | 43 static void SzFileFree(void* p, void* address); |
47 | 44 |
48 base::FilePath mapped_file_path_; | 45 base::FilePath mapped_file_path_; |
49 base::File mapped_file_; | 46 base::File mapped_file_; |
50 base::win::ScopedHandle file_mapping_handle_; | 47 base::win::ScopedHandle file_mapping_handle_; |
51 | 48 |
52 DISALLOW_COPY_AND_ASSIGN(LzmaFileAllocator); | 49 DISALLOW_COPY_AND_ASSIGN(LzmaFileAllocator); |
53 }; | 50 }; |
54 | 51 |
55 #endif // CHROME_INSTALLER_UTIL_LZMA_FILE_ALLOCATOR_H_ | 52 #endif // CHROME_INSTALLER_UTIL_LZMA_FILE_ALLOCATOR_H_ |
OLD | NEW |