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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 bool HandleTable::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 159 bool HandleTable::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 165 base::trace_event::ProcessMemoryDump* pmd) { | 160 base::trace_event::ProcessMemoryDump* pmd) { |
| 166 // Create entries for all relevant dispatcher types to ensure they are present | 161 // Create entries for all relevant dispatcher types to ensure they are present |
| 167 // in the final dump. | 162 // in the final dump. |
| 168 std::map<Dispatcher::Type, int> handle_count; | 163 std::map<Dispatcher::Type, int> handle_count; |
| 169 handle_count[Dispatcher::Type::MESSAGE_PIPE]; | 164 handle_count[Dispatcher::Type::MESSAGE_PIPE]; |
| 170 handle_count[Dispatcher::Type::DATA_PIPE_PRODUCER]; | 165 handle_count[Dispatcher::Type::DATA_PIPE_PRODUCER]; |
| 171 handle_count[Dispatcher::Type::DATA_PIPE_CONSUMER]; | 166 handle_count[Dispatcher::Type::DATA_PIPE_CONSUMER]; |
| 172 handle_count[Dispatcher::Type::SHARED_BUFFER]; | 167 handle_count[Dispatcher::Type::SHARED_BUFFER]; |
| 173 handle_count[Dispatcher::Type::WATCHER]; | 168 handle_count[Dispatcher::Type::WATCHER]; |
| 174 handle_count[Dispatcher::Type::PLATFORM_HANDLE]; | 169 handle_count[Dispatcher::Type::PLATFORM_HANDLE]; |
|
ssid
2017/06/08 18:12:36
Are these lines required? The last time I tested j
erikchen
2017/06/09 00:18:12
As I commented above, this causes the entries to b
ssid
2017/06/09 00:38:28
Acknowledged.
| |
| 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 base::trace_event::MemoryAllocatorDump* outer_dump = | 179 base::trace_event::MemoryAllocatorDump* outer_dump = |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 196 | 191 |
| 197 HandleTable::Entry::Entry(scoped_refptr<Dispatcher> dispatcher) | 192 HandleTable::Entry::Entry(scoped_refptr<Dispatcher> dispatcher) |
| 198 : dispatcher(std::move(dispatcher)) {} | 193 : dispatcher(std::move(dispatcher)) {} |
| 199 | 194 |
| 200 HandleTable::Entry::Entry(const Entry& other) = default; | 195 HandleTable::Entry::Entry(const Entry& other) = default; |
| 201 | 196 |
| 202 HandleTable::Entry::~Entry() {} | 197 HandleTable::Entry::~Entry() {} |
| 203 | 198 |
| 204 } // namespace edk | 199 } // namespace edk |
| 205 } // namespace mojo | 200 } // namespace mojo |
| OLD | NEW |