| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/embedder/simple_platform_shared_buffer.h" | 5 #include "mojo/embedder/simple_platform_shared_buffer.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 DCHECK_LE(static_cast<uint64_t>(real_offset), | 68 DCHECK_LE(static_cast<uint64_t>(real_offset), |
| 69 static_cast<uint64_t>(std::numeric_limits<DWORD>::max())); | 69 static_cast<uint64_t>(std::numeric_limits<DWORD>::max())); |
| 70 | 70 |
| 71 void* real_base = MapViewOfFile(handle_.get().handle, | 71 void* real_base = MapViewOfFile(handle_.get().handle, |
| 72 FILE_MAP_READ | FILE_MAP_WRITE, | 72 FILE_MAP_READ | FILE_MAP_WRITE, |
| 73 0, | 73 0, |
| 74 static_cast<DWORD>(real_offset), | 74 static_cast<DWORD>(real_offset), |
| 75 real_length); | 75 real_length); |
| 76 if (!real_base) { | 76 if (!real_base) { |
| 77 PLOG(ERROR) << "MapViewOfFile"; | 77 PLOG(ERROR) << "MapViewOfFile"; |
| 78 return scoped_ptr<PlatformSharedBufferMapping>(); | 78 return nullptr; |
| 79 } | 79 } |
| 80 | 80 |
| 81 void* base = static_cast<char*>(real_base) + offset_rounding; | 81 void* base = static_cast<char*>(real_base) + offset_rounding; |
| 82 return scoped_ptr<PlatformSharedBufferMapping>( | 82 return scoped_ptr<PlatformSharedBufferMapping>( |
| 83 new SimplePlatformSharedBufferMapping( | 83 new SimplePlatformSharedBufferMapping( |
| 84 base, length, real_base, real_length)); | 84 base, length, real_base, real_length)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // SimplePlatformSharedBufferMapping ------------------------------------------- | 87 // SimplePlatformSharedBufferMapping ------------------------------------------- |
| 88 | 88 |
| 89 void SimplePlatformSharedBufferMapping::Unmap() { | 89 void SimplePlatformSharedBufferMapping::Unmap() { |
| 90 BOOL result = UnmapViewOfFile(real_base_); | 90 BOOL result = UnmapViewOfFile(real_base_); |
| 91 PLOG_IF(ERROR, !result) << "UnmapViewOfFile"; | 91 PLOG_IF(ERROR, !result) << "UnmapViewOfFile"; |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace embedder | 94 } // namespace embedder |
| 95 } // namespace mojo | 95 } // namespace mojo |
| OLD | NEW |