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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
8 #include "base/process/kill.h" | 8 #include "base/process/kill.h" |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // This test requires the ability to pass file descriptors between processes. | 94 // This test requires the ability to pass file descriptors between processes. |
95 // We haven't done that yet in Chrome for POSIX. | 95 // We haven't done that yet in Chrome for POSIX. |
96 #if defined(OS_WIN) | 96 #if defined(OS_WIN) |
97 // Each thread will open the shared memory. Each thread will take the memory, | 97 // Each thread will open the shared memory. Each thread will take the memory, |
98 // and keep changing it while trying to lock it, with some small pauses in | 98 // and keep changing it while trying to lock it, with some small pauses in |
99 // between. Verify that each thread's value in the shared memory is always | 99 // between. Verify that each thread's value in the shared memory is always |
100 // correct. | 100 // correct. |
101 class MultipleLockThread : public PlatformThread::Delegate { | 101 class MultipleLockThread : public PlatformThread::Delegate { |
102 public: | 102 public: |
103 explicit MultipleLockThread(int id) : id_(id) {} | 103 explicit MultipleLockThread(int id) : id_(id) {} |
104 virtual ~MultipleLockThread() {} | 104 ~MultipleLockThread() override {} |
105 | 105 |
106 // PlatformThread::Delegate interface. | 106 // PlatformThread::Delegate interface. |
107 virtual void ThreadMain() override { | 107 void ThreadMain() override { |
108 const uint32 kDataSize = sizeof(int); | 108 const uint32 kDataSize = sizeof(int); |
109 SharedMemoryHandle handle = NULL; | 109 SharedMemoryHandle handle = NULL; |
110 { | 110 { |
111 SharedMemory memory1; | 111 SharedMemory memory1; |
112 EXPECT_TRUE(memory1.CreateNamedDeprecated( | 112 EXPECT_TRUE(memory1.CreateNamedDeprecated( |
113 "SharedMemoryMultipleLockThreadTest", true, kDataSize)); | 113 "SharedMemoryMultipleLockThreadTest", true, kDataSize)); |
114 EXPECT_TRUE(memory1.ShareToProcess(GetCurrentProcess(), &handle)); | 114 EXPECT_TRUE(memory1.ShareToProcess(GetCurrentProcess(), &handle)); |
115 // TODO(paulg): Implement this once we have a posix version of | 115 // TODO(paulg): Implement this once we have a posix version of |
116 // SharedMemory::ShareToProcess. | 116 // SharedMemory::ShareToProcess. |
117 EXPECT_TRUE(true); | 117 EXPECT_TRUE(true); |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 SharedMemoryProcessTest::CleanUp(); | 714 SharedMemoryProcessTest::CleanUp(); |
715 } | 715 } |
716 | 716 |
717 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) { | 717 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) { |
718 return SharedMemoryProcessTest::TaskTestMain(); | 718 return SharedMemoryProcessTest::TaskTestMain(); |
719 } | 719 } |
720 | 720 |
721 #endif // !OS_IOS | 721 #endif // !OS_IOS |
722 | 722 |
723 } // namespace base | 723 } // namespace base |
OLD | NEW |