| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/atomicops.h" | 8 #include "base/atomicops.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 shared_memory.Close(); | 582 shared_memory.Close(); |
| 583 } | 583 } |
| 584 | 584 |
| 585 #if defined(OS_WIN) | 585 #if defined(OS_WIN) |
| 586 TEST(SharedMemoryTest, UnsafeImageSection) { | 586 TEST(SharedMemoryTest, UnsafeImageSection) { |
| 587 const char kTestSectionName[] = "UnsafeImageSection"; | 587 const char kTestSectionName[] = "UnsafeImageSection"; |
| 588 wchar_t path[MAX_PATH]; | 588 wchar_t path[MAX_PATH]; |
| 589 EXPECT_GT(::GetModuleFileName(nullptr, path, arraysize(path)), 0U); | 589 EXPECT_GT(::GetModuleFileName(nullptr, path, arraysize(path)), 0U); |
| 590 | 590 |
| 591 // Map the current executable image to save us creating a new PE file on disk. | 591 // Map the current executable image to save us creating a new PE file on disk. |
| 592 base::win::ScopedHandle file_handle( | 592 base::win::ScopedHandle file_handle(::CreateFile( |
| 593 ::CreateFile(path, GENERIC_READ, 0, nullptr, OPEN_EXISTING, 0, nullptr)); | 593 path, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr)); |
| 594 EXPECT_TRUE(file_handle.IsValid()); | 594 EXPECT_TRUE(file_handle.IsValid()); |
| 595 base::win::ScopedHandle section_handle( | 595 base::win::ScopedHandle section_handle( |
| 596 ::CreateFileMappingA(file_handle.Get(), nullptr, | 596 ::CreateFileMappingA(file_handle.Get(), nullptr, |
| 597 PAGE_READONLY | SEC_IMAGE, 0, 0, kTestSectionName)); | 597 PAGE_READONLY | SEC_IMAGE, 0, 0, kTestSectionName)); |
| 598 EXPECT_TRUE(section_handle.IsValid()); | 598 EXPECT_TRUE(section_handle.IsValid()); |
| 599 | 599 |
| 600 // Check direct opening by name, from handle and duplicated from handle. | 600 // Check direct opening by name, from handle and duplicated from handle. |
| 601 SharedMemory shared_memory_open; | 601 SharedMemory shared_memory_open; |
| 602 EXPECT_TRUE(shared_memory_open.Open(kTestSectionName, true)); | 602 EXPECT_TRUE(shared_memory_open.Open(kTestSectionName, true)); |
| 603 EXPECT_FALSE(shared_memory_open.Map(1)); | 603 EXPECT_FALSE(shared_memory_open.Map(1)); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 memory.Close(); | 704 memory.Close(); |
| 705 SharedMemoryProcessTest::CleanUp(); | 705 SharedMemoryProcessTest::CleanUp(); |
| 706 } | 706 } |
| 707 | 707 |
| 708 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) { | 708 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) { |
| 709 return SharedMemoryProcessTest::TaskTestMain(); | 709 return SharedMemoryProcessTest::TaskTestMain(); |
| 710 } | 710 } |
| 711 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 711 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
| 712 | 712 |
| 713 } // namespace base | 713 } // namespace base |
| OLD | NEW |