Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1467)

Unified Diff: content/browser/mach_broker_mac_unittest.cc

Issue 681733003: Removed the ProcessHandle from the RendererClosedDetails payload (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Used range-based loop Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/mach_broker_mac_unittest.cc
diff --git a/content/browser/mach_broker_mac_unittest.cc b/content/browser/mach_broker_mac_unittest.cc
index a7eca4fd2f4ff770d181bfec2598d224d42dc7af..730a46d544f0d44f365528ee8b9216c6e4f72e0b 100644
--- a/content/browser/mach_broker_mac_unittest.cc
+++ b/content/browser/mach_broker_mac_unittest.cc
@@ -12,15 +12,28 @@ namespace content {
class MachBrokerTest : public testing::Test {
public:
// Helper function to acquire/release locks and call |PlaceholderForPid()|.
- void AddPlaceholderForPid(base::ProcessHandle pid) {
+ void AddPlaceholderForPid(base::ProcessHandle pid, int child_process_id) {
base::AutoLock lock(broker_.GetLock());
- broker_.AddPlaceholderForPid(pid);
+ broker_.AddPlaceholderForPid(pid, child_process_id);
}
void InvalidatePid(base::ProcessHandle pid) {
broker_.InvalidatePid(pid);
}
+ void InvalidateChildProcessId(int child_process_id) {
+ broker_.InvalidateChildProcessId(child_process_id);
+ }
+
+ int GetChildProcessCount(int child_process_id) {
+ int count = 0;
+ for (const auto& it : broker_.child_process_id_map_) {
+ if (it.second == child_process_id)
+ count++;
+ }
+ return count;
+ }
+
// Helper function to acquire/release locks and call |FinalizePid()|.
void FinalizePid(base::ProcessHandle pid,
mach_port_t task_port) {
@@ -39,7 +52,7 @@ TEST_F(MachBrokerTest, Locks) {
TEST_F(MachBrokerTest, AddPlaceholderAndFinalize) {
// Add a placeholder for PID 1.
- AddPlaceholderForPid(1);
+ AddPlaceholderForPid(1, 1);
EXPECT_EQ(0u, broker_.TaskForPid(1));
// Finalize PID 1.
@@ -51,7 +64,7 @@ TEST_F(MachBrokerTest, AddPlaceholderAndFinalize) {
}
TEST_F(MachBrokerTest, Invalidate) {
- AddPlaceholderForPid(1);
+ AddPlaceholderForPid(1, 1);
FinalizePid(1, 100u);
EXPECT_EQ(100u, broker_.TaskForPid(1));
@@ -59,6 +72,26 @@ TEST_F(MachBrokerTest, Invalidate) {
EXPECT_EQ(0u, broker_.TaskForPid(1));
}
+TEST_F(MachBrokerTest, InvalidateChildProcessId) {
+ // Add a placeholder for PID 1 and child process id 50.
+ AddPlaceholderForPid(1, 50);
+ FinalizePid(1, 100u);
+
+ EXPECT_EQ(100u, broker_.TaskForPid(1));
+ InvalidateChildProcessId(50);
+ EXPECT_EQ(0u, broker_.TaskForPid(1));
+}
+
+TEST_F(MachBrokerTest, ValidateChildProcessIdMap) {
+ // Add a placeholder for PID 1 and child process id 50.
+ AddPlaceholderForPid(1, 50);
+ FinalizePid(1, 100u);
+
+ EXPECT_EQ(1, GetChildProcessCount(50));
+ InvalidateChildProcessId(50);
+ EXPECT_EQ(0, GetChildProcessCount(50));
+}
+
TEST_F(MachBrokerTest, FinalizeUnknownPid) {
// Finalizing an entry for an unknown pid should not add it to the map.
FinalizePid(1u, 100u);

Powered by Google App Engine
This is Rietveld 408576698