| 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 #include "courgette/memory_allocator.h" | 5 #include "courgette/memory_allocator.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 void TempFile::Close() { | 25 void TempFile::Close() { |
| 26 if (valid()) { | 26 if (valid()) { |
| 27 base::ClosePlatformFile(file_); | 27 base::ClosePlatformFile(file_); |
| 28 file_ = base::kInvalidPlatformFileValue; | 28 file_ = base::kInvalidPlatformFileValue; |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 bool TempFile::Create() { | 32 bool TempFile::Create() { |
| 33 DCHECK(file_ == base::kInvalidPlatformFileValue); | 33 DCHECK(file_ == base::kInvalidPlatformFileValue); |
| 34 base::FilePath path; | 34 base::FilePath path; |
| 35 if (!file_util::CreateTemporaryFile(&path)) | 35 if (!base::CreateTemporaryFile(&path)) |
| 36 return false; | 36 return false; |
| 37 | 37 |
| 38 bool created = false; | 38 bool created = false; |
| 39 base::PlatformFileError error_code = base::PLATFORM_FILE_OK; | 39 base::PlatformFileError error_code = base::PLATFORM_FILE_OK; |
| 40 int flags = base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_READ | | 40 int flags = base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_READ | |
| 41 base::PLATFORM_FILE_WRITE | | 41 base::PLATFORM_FILE_WRITE | |
| 42 base::PLATFORM_FILE_DELETE_ON_CLOSE | | 42 base::PLATFORM_FILE_DELETE_ON_CLOSE | |
| 43 base::PLATFORM_FILE_TEMPORARY; | 43 base::PLATFORM_FILE_TEMPORARY; |
| 44 file_ = base::CreatePlatformFile(path, flags, &created, &error_code); | 44 file_ = base::CreatePlatformFile(path, flags, &created, &error_code); |
| 45 if (file_ == base::kInvalidPlatformFileValue) | 45 if (file_ == base::kInvalidPlatformFileValue) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (mem) { | 153 if (mem) { |
| 154 ret = reinterpret_cast<TempMapping**>(mem)[-1]; | 154 ret = reinterpret_cast<TempMapping**>(mem)[-1]; |
| 155 } | 155 } |
| 156 DCHECK(ret); | 156 DCHECK(ret); |
| 157 return ret; | 157 return ret; |
| 158 } | 158 } |
| 159 | 159 |
| 160 } // namespace courgette | 160 } // namespace courgette |
| 161 | 161 |
| 162 #endif // OS_WIN | 162 #endif // OS_WIN |
| OLD | NEW |