| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/metrics/stats_table.h" | 5 #include "base/metrics/stats_table.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 | 471 |
| 472 int* StatsTable::FindLocation(const char* name) { | 472 int* StatsTable::FindLocation(const char* name) { |
| 473 // Get the static StatsTable | 473 // Get the static StatsTable |
| 474 StatsTable *table = StatsTable::current(); | 474 StatsTable *table = StatsTable::current(); |
| 475 if (!table) | 475 if (!table) |
| 476 return NULL; | 476 return NULL; |
| 477 | 477 |
| 478 // Get the slot for this thread. Try to register | 478 // Get the slot for this thread. Try to register |
| 479 // it if none exists. | 479 // it if none exists. |
| 480 int slot = table->GetSlot(); | 480 int slot = table->GetSlot(); |
| 481 if (!slot && !(slot = table->RegisterThread(std::string()))) | 481 if (!slot) |
| 482 slot = table->RegisterThread(std::string()); |
| 483 if (!slot) |
| 482 return NULL; | 484 return NULL; |
| 483 | 485 |
| 484 // Find the counter id for the counter. | 486 // Find the counter id for the counter. |
| 485 std::string str_name(name); | 487 std::string str_name(name); |
| 486 int counter = table->FindCounter(str_name); | 488 int counter = table->FindCounter(str_name); |
| 487 | 489 |
| 488 // Now we can find the location in the table. | 490 // Now we can find the location in the table. |
| 489 return table->GetLocation(counter, slot); | 491 return table->GetLocation(counter, slot); |
| 490 } | 492 } |
| 491 | 493 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 | 608 |
| 607 #if defined(OS_POSIX) | 609 #if defined(OS_POSIX) |
| 608 SharedMemoryHandle StatsTable::GetSharedMemoryHandle() const { | 610 SharedMemoryHandle StatsTable::GetSharedMemoryHandle() const { |
| 609 if (!internal_) | 611 if (!internal_) |
| 610 return SharedMemory::NULLHandle(); | 612 return SharedMemory::NULLHandle(); |
| 611 return internal_->shared_memory()->handle(); | 613 return internal_->shared_memory()->handle(); |
| 612 } | 614 } |
| 613 #endif | 615 #endif |
| 614 | 616 |
| 615 } // namespace base | 617 } // namespace base |
| OLD | NEW |