OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "content/browser/mach_broker_mac.h" | 5 #include "content/browser/mach_broker_mac.h" |
6 | 6 |
7 #include "base/synchronization/lock.h" | 7 #include "base/synchronization/lock.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
(...skipping 11 matching lines...) Expand all Loading... |
22 } | 22 } |
23 | 23 |
24 int GetChildProcessCount(int child_process_id) { | 24 int GetChildProcessCount(int child_process_id) { |
25 return broker_.child_process_id_map_.count(child_process_id); | 25 return broker_.child_process_id_map_.count(child_process_id); |
26 } | 26 } |
27 | 27 |
28 // Helper function to acquire/release locks and call |FinalizePid()|. | 28 // Helper function to acquire/release locks and call |FinalizePid()|. |
29 void FinalizePid(base::ProcessHandle pid, | 29 void FinalizePid(base::ProcessHandle pid, |
30 mach_port_t task_port) { | 30 mach_port_t task_port) { |
31 base::AutoLock lock(broker_.GetLock()); | 31 base::AutoLock lock(broker_.GetLock()); |
32 broker_.FinalizePid(pid, task_port); | 32 broker_.broker_.FinalizePid(pid, task_port); |
33 } | 33 } |
34 | 34 |
35 protected: | 35 protected: |
36 MachBroker broker_; | 36 MachBroker broker_; |
37 }; | 37 }; |
38 | 38 |
39 TEST_F(MachBrokerTest, Locks) { | 39 TEST_F(MachBrokerTest, Locks) { |
40 // Acquire and release the locks. Nothing bad should happen. | 40 // Acquire and release the locks. Nothing bad should happen. |
41 base::AutoLock lock(broker_.GetLock()); | 41 base::AutoLock lock(broker_.GetLock()); |
42 } | 42 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 EXPECT_EQ(0, GetChildProcessCount(50)); | 74 EXPECT_EQ(0, GetChildProcessCount(50)); |
75 } | 75 } |
76 | 76 |
77 TEST_F(MachBrokerTest, FinalizeUnknownPid) { | 77 TEST_F(MachBrokerTest, FinalizeUnknownPid) { |
78 // Finalizing an entry for an unknown pid should not add it to the map. | 78 // Finalizing an entry for an unknown pid should not add it to the map. |
79 FinalizePid(1u, 100u); | 79 FinalizePid(1u, 100u); |
80 EXPECT_EQ(0u, broker_.TaskForPid(1u)); | 80 EXPECT_EQ(0u, broker_.TaskForPid(1u)); |
81 } | 81 } |
82 | 82 |
83 } // namespace content | 83 } // namespace content |
OLD | NEW |