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 16 matching lines...) Expand all Loading... |
27 return false; | 27 return false; |
28 } | 28 } |
29 | 29 |
30 // IMPORTANT NOTE: Unnamed objects are NOT SECURABLE. Thus if we ever want to | 30 // IMPORTANT NOTE: Unnamed objects are NOT SECURABLE. Thus if we ever want to |
31 // share read-only to other processes, we'll have to name our file mapping | 31 // share read-only to other processes, we'll have to name our file mapping |
32 // object. | 32 // object. |
33 // TODO(vtl): Unlike |base::SharedMemory|, we don't round up the size (to a | 33 // TODO(vtl): Unlike |base::SharedMemory|, we don't round up the size (to a |
34 // multiple of 64 KB). This may cause problems with NaCl. Cross this bridge | 34 // multiple of 64 KB). This may cause problems with NaCl. Cross this bridge |
35 // when we get there. crbug.com/210609 | 35 // when we get there. crbug.com/210609 |
36 handle_.reset(PlatformHandle(CreateFileMapping(INVALID_HANDLE_VALUE, | 36 handle_.reset(PlatformHandle(CreateFileMapping(INVALID_HANDLE_VALUE, |
37 NULL, | 37 nullptr, |
38 PAGE_READWRITE, | 38 PAGE_READWRITE, |
39 0, | 39 0, |
40 static_cast<DWORD>(num_bytes_), | 40 static_cast<DWORD>(num_bytes_), |
41 NULL))); | 41 nullptr))); |
42 if (!handle_.is_valid()) { | 42 if (!handle_.is_valid()) { |
43 PLOG(ERROR) << "CreateFileMapping"; | 43 PLOG(ERROR) << "CreateFileMapping"; |
44 return false; | 44 return false; |
45 } | 45 } |
46 | 46 |
47 return true; | 47 return true; |
48 } | 48 } |
49 | 49 |
50 bool SimplePlatformSharedBuffer::InitFromPlatformHandle( | 50 bool SimplePlatformSharedBuffer::InitFromPlatformHandle( |
51 ScopedPlatformHandle platform_handle) { | 51 ScopedPlatformHandle platform_handle) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |