Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/edk/system/handle_table.h" | 5 #include "mojo/edk/system/handle_table.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 return "data_pipe_producer"; | 25 return "data_pipe_producer"; |
| 26 case Dispatcher::Type::DATA_PIPE_CONSUMER: | 26 case Dispatcher::Type::DATA_PIPE_CONSUMER: |
| 27 return "data_pipe_consumer"; | 27 return "data_pipe_consumer"; |
| 28 case Dispatcher::Type::SHARED_BUFFER: | 28 case Dispatcher::Type::SHARED_BUFFER: |
| 29 return "shared_buffer"; | 29 return "shared_buffer"; |
| 30 case Dispatcher::Type::WATCHER: | 30 case Dispatcher::Type::WATCHER: |
| 31 return "watcher"; | 31 return "watcher"; |
| 32 case Dispatcher::Type::PLATFORM_HANDLE: | 32 case Dispatcher::Type::PLATFORM_HANDLE: |
| 33 return "platform_handle"; | 33 return "platform_handle"; |
| 34 } | 34 } |
| 35 NOTREACHED(); | |
| 35 return "unknown"; | 36 return "unknown"; |
| 36 } | 37 } |
| 37 | 38 |
| 38 const char* kDumpProviderName = "MojoHandleTable"; | |
| 39 | |
| 40 } // namespace | 39 } // namespace |
| 41 | 40 |
| 42 HandleTable::HandleTable() { | 41 HandleTable::HandleTable() { |
| 43 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( | |
| 44 this, kDumpProviderName, nullptr); | |
| 45 } | 42 } |
| 46 | 43 |
| 47 HandleTable::~HandleTable() { | 44 HandleTable::~HandleTable() { |
| 48 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( | |
| 49 this, kDumpProviderName, nullptr); | |
| 50 } | 45 } |
| 51 | 46 |
| 52 base::Lock& HandleTable::GetLock() { | 47 base::Lock& HandleTable::GetLock() { |
| 53 return lock_; | 48 return lock_; |
| 54 } | 49 } |
| 55 | 50 |
| 56 MojoHandle HandleTable::AddDispatcher(scoped_refptr<Dispatcher> dispatcher) { | 51 MojoHandle HandleTable::AddDispatcher(scoped_refptr<Dispatcher> dispatcher) { |
| 57 // Oops, we're out of handles. | 52 // Oops, we're out of handles. |
| 58 if (next_available_handle_ == MOJO_HANDLE_INVALID) | 53 if (next_available_handle_ == MOJO_HANDLE_INVALID) |
| 59 return MOJO_HANDLE_INVALID; | 54 return MOJO_HANDLE_INVALID; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 handle_count[Dispatcher::Type::PLATFORM_HANDLE]; | 169 handle_count[Dispatcher::Type::PLATFORM_HANDLE]; |
| 175 | 170 |
| 176 // Count the number of each dispatcher type. | 171 // Count the number of each dispatcher type. |
| 177 { | 172 { |
| 178 base::AutoLock lock(GetLock()); | 173 base::AutoLock lock(GetLock()); |
| 179 for (const auto& entry : handles_) { | 174 for (const auto& entry : handles_) { |
| 180 ++handle_count[entry.second.dispatcher->GetType()]; | 175 ++handle_count[entry.second.dispatcher->GetType()]; |
| 181 } | 176 } |
| 182 } | 177 } |
| 183 | 178 |
| 184 pmd->CreateAllocatorDump("mojo"); | 179 pmd->CreateAllocatorDump("mojo"); |
|
ssid
2017/06/09 00:38:28
This line is not required.
| |
| 185 for (const auto& entry : handle_count) { | 180 for (const auto& entry : handle_count) { |
| 186 base::trace_event::MemoryAllocatorDump* inner_dump = | 181 base::trace_event::MemoryAllocatorDump* inner_dump = |
| 187 pmd->CreateAllocatorDump(std::string("mojo/") + | 182 pmd->CreateAllocatorDump(std::string("mojo/") + |
| 188 GetNameForDispatcherType(entry.first)); | 183 GetNameForDispatcherType(entry.first)); |
| 189 inner_dump->AddScalar( | 184 inner_dump->AddScalar( |
| 190 base::trace_event::MemoryAllocatorDump::kNameObjectCount, | 185 base::trace_event::MemoryAllocatorDump::kNameObjectCount, |
| 191 base::trace_event::MemoryAllocatorDump::kUnitsObjects, entry.second); | 186 base::trace_event::MemoryAllocatorDump::kUnitsObjects, entry.second); |
| 192 } | 187 } |
| 193 | 188 |
| 194 return true; | 189 return true; |
| 195 } | 190 } |
| 196 | 191 |
| 197 HandleTable::Entry::Entry() {} | 192 HandleTable::Entry::Entry() {} |
| 198 | 193 |
| 199 HandleTable::Entry::Entry(scoped_refptr<Dispatcher> dispatcher) | 194 HandleTable::Entry::Entry(scoped_refptr<Dispatcher> dispatcher) |
| 200 : dispatcher(std::move(dispatcher)) {} | 195 : dispatcher(std::move(dispatcher)) {} |
| 201 | 196 |
| 202 HandleTable::Entry::Entry(const Entry& other) = default; | 197 HandleTable::Entry::Entry(const Entry& other) = default; |
| 203 | 198 |
| 204 HandleTable::Entry::~Entry() {} | 199 HandleTable::Entry::~Entry() {} |
| 205 | 200 |
| 206 } // namespace edk | 201 } // namespace edk |
| 207 } // namespace mojo | 202 } // namespace mojo |
| OLD | NEW |