| 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/memory/shared_memory.h" | 5 #include "base/memory/shared_memory.h" |
| 6 #include "base/metrics/stats_counters.h" | 6 #include "base/metrics/stats_counters.h" |
| 7 #include "base/metrics/stats_table.h" | 7 #include "base/metrics/stats_table.h" |
| 8 #include "base/process/kill.h" | 8 #include "base/process/kill.h" |
| 9 #include "base/strings/string_piece.h" | 9 #include "base/strings/string_piece.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 StatsTable::set_current(&table); | 204 StatsTable::set_current(&table); |
| 205 EXPECT_EQ(0, table.CountThreadsRegistered()); | 205 EXPECT_EQ(0, table.CountThreadsRegistered()); |
| 206 | 206 |
| 207 // Spin up a set of processes to go bang on the various counters. | 207 // Spin up a set of processes to go bang on the various counters. |
| 208 // After we join the processes, we'll make sure the counters | 208 // After we join the processes, we'll make sure the counters |
| 209 // contain the values we expected. | 209 // contain the values we expected. |
| 210 ProcessHandle procs[kMaxProcs]; | 210 ProcessHandle procs[kMaxProcs]; |
| 211 | 211 |
| 212 // Spawn the processes. | 212 // Spawn the processes. |
| 213 for (int16 index = 0; index < kMaxProcs; index++) { | 213 for (int16 index = 0; index < kMaxProcs; index++) { |
| 214 procs[index] = this->SpawnChild("StatsTableMultipleProcessMain", false); | 214 procs[index] = SpawnChild("StatsTableMultipleProcessMain"); |
| 215 EXPECT_NE(kNullProcessHandle, procs[index]); | 215 EXPECT_NE(kNullProcessHandle, procs[index]); |
| 216 } | 216 } |
| 217 | 217 |
| 218 // Wait for the processes to finish. | 218 // Wait for the processes to finish. |
| 219 for (int index = 0; index < kMaxProcs; index++) { | 219 for (int index = 0; index < kMaxProcs; index++) { |
| 220 EXPECT_TRUE(WaitForSingleProcess( | 220 EXPECT_TRUE(WaitForSingleProcess( |
| 221 procs[index], base::TimeDelta::FromMinutes(1))); | 221 procs[index], base::TimeDelta::FromMinutes(1))); |
| 222 CloseProcessHandle(procs[index]); | 222 CloseProcessHandle(procs[index]); |
| 223 } | 223 } |
| 224 | 224 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 PlatformThread::Sleep(kDuration); | 415 PlatformThread::Sleep(kDuration); |
| 416 } | 416 } |
| 417 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo")); | 417 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo")); |
| 418 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar")); | 418 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar")); |
| 419 EXPECT_EQ(2, table.GetCounterValue("c:bar")); | 419 EXPECT_EQ(2, table.GetCounterValue("c:bar")); |
| 420 | 420 |
| 421 DeleteShmem(kTableName); | 421 DeleteShmem(kTableName); |
| 422 } | 422 } |
| 423 | 423 |
| 424 } // namespace base | 424 } // namespace base |
| OLD | NEW |