| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/v8_inspector/V8HeapProfilerAgentImpl.h" | 5 #include "platform/v8_inspector/V8HeapProfilerAgentImpl.h" |
| 6 | 6 |
| 7 #include "platform/v8_inspector/InjectedScript.h" | 7 #include "platform/v8_inspector/InjectedScript.h" |
| 8 #include "platform/v8_inspector/V8DebuggerImpl.h" | 8 #include "platform/v8_inspector/V8DebuggerImpl.h" |
| 9 #include "platform/v8_inspector/V8InspectorSessionImpl.h" | 9 #include "platform/v8_inspector/V8InspectorSessionImpl.h" |
| 10 #include "platform/v8_inspector/V8StringUtil.h" | 10 #include "platform/v8_inspector/V8StringUtil.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 public: | 119 public: |
| 120 HeapStatsStream(protocol::Frontend::HeapProfiler* frontend) | 120 HeapStatsStream(protocol::Frontend::HeapProfiler* frontend) |
| 121 : m_frontend(frontend) | 121 : m_frontend(frontend) |
| 122 { | 122 { |
| 123 } | 123 } |
| 124 | 124 |
| 125 void EndOfStream() override { } | 125 void EndOfStream() override { } |
| 126 | 126 |
| 127 WriteResult WriteAsciiChunk(char* data, int size) override | 127 WriteResult WriteAsciiChunk(char* data, int size) override |
| 128 { | 128 { |
| 129 ASSERT(false); | 129 DCHECK(false); |
| 130 return kAbort; | 130 return kAbort; |
| 131 } | 131 } |
| 132 | 132 |
| 133 WriteResult WriteHeapStatsChunk(v8::HeapStatsUpdate* updateData, int count)
override | 133 WriteResult WriteHeapStatsChunk(v8::HeapStatsUpdate* updateData, int count)
override |
| 134 { | 134 { |
| 135 ASSERT(count > 0); | 135 DCHECK_GT(count, 0); |
| 136 OwnPtr<protocol::Array<int>> statsDiff = protocol::Array<int>::create(); | 136 OwnPtr<protocol::Array<int>> statsDiff = protocol::Array<int>::create(); |
| 137 for (int i = 0; i < count; ++i) { | 137 for (int i = 0; i < count; ++i) { |
| 138 statsDiff->addItem(updateData[i].index); | 138 statsDiff->addItem(updateData[i].index); |
| 139 statsDiff->addItem(updateData[i].count); | 139 statsDiff->addItem(updateData[i].count); |
| 140 statsDiff->addItem(updateData[i].size); | 140 statsDiff->addItem(updateData[i].size); |
| 141 } | 141 } |
| 142 m_frontend->heapStatsUpdate(std::move(statsDiff)); | 142 m_frontend->heapStatsUpdate(std::move(statsDiff)); |
| 143 return kContinue; | 143 return kContinue; |
| 144 } | 144 } |
| 145 | 145 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 157 } | 157 } |
| 158 | 158 |
| 159 V8HeapProfilerAgentImpl::~V8HeapProfilerAgentImpl() | 159 V8HeapProfilerAgentImpl::~V8HeapProfilerAgentImpl() |
| 160 { | 160 { |
| 161 } | 161 } |
| 162 | 162 |
| 163 void V8HeapProfilerAgentImpl::clearFrontend() | 163 void V8HeapProfilerAgentImpl::clearFrontend() |
| 164 { | 164 { |
| 165 ErrorString error; | 165 ErrorString error; |
| 166 disable(&error); | 166 disable(&error); |
| 167 ASSERT(m_frontend); | 167 DCHECK(m_frontend); |
| 168 m_frontend = nullptr; | 168 m_frontend = nullptr; |
| 169 } | 169 } |
| 170 | 170 |
| 171 void V8HeapProfilerAgentImpl::restore() | 171 void V8HeapProfilerAgentImpl::restore() |
| 172 { | 172 { |
| 173 if (m_state->booleanProperty(HeapProfilerAgentState::heapProfilerEnabled, fa
lse)) | 173 if (m_state->booleanProperty(HeapProfilerAgentState::heapProfilerEnabled, fa
lse)) |
| 174 m_frontend->resetProfiles(); | 174 m_frontend->resetProfiles(); |
| 175 if (m_state->booleanProperty(HeapProfilerAgentState::heapObjectsTrackingEnab
led, false)) | 175 if (m_state->booleanProperty(HeapProfilerAgentState::heapObjectsTrackingEnab
led, false)) |
| 176 startTrackingHeapObjectsInternal(m_state->booleanProperty(HeapProfilerAg
entState::allocationTrackingEnabled, false)); | 176 startTrackingHeapObjectsInternal(m_state->booleanProperty(HeapProfilerAg
entState::allocationTrackingEnabled, false)); |
| 177 #if V8_MAJOR_VERSION >= 5 | 177 #if V8_MAJOR_VERSION >= 5 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 *errorString = "Cannot access v8 sampled heap profile."; | 400 *errorString = "Cannot access v8 sampled heap profile."; |
| 401 return; | 401 return; |
| 402 } | 402 } |
| 403 v8::AllocationProfile::Node* root = v8Profile->GetRootNode(); | 403 v8::AllocationProfile::Node* root = v8Profile->GetRootNode(); |
| 404 *profile = protocol::HeapProfiler::SamplingHeapProfile::create() | 404 *profile = protocol::HeapProfiler::SamplingHeapProfile::create() |
| 405 .setHead(buildSampingHeapProfileNode(root)).build(); | 405 .setHead(buildSampingHeapProfileNode(root)).build(); |
| 406 #endif | 406 #endif |
| 407 } | 407 } |
| 408 | 408 |
| 409 } // namespace blink | 409 } // namespace blink |
| OLD | NEW |