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/StringUtil.h" |
8 #include "platform/v8_inspector/V8Debugger.h" | 9 #include "platform/v8_inspector/V8Debugger.h" |
9 #include "platform/v8_inspector/V8InspectorImpl.h" | 10 #include "platform/v8_inspector/V8InspectorImpl.h" |
10 #include "platform/v8_inspector/V8InspectorSessionImpl.h" | 11 #include "platform/v8_inspector/V8InspectorSessionImpl.h" |
11 #include "platform/v8_inspector/V8StringUtil.h" | 12 #include "platform/v8_inspector/protocol/Protocol.h" |
12 #include "platform/v8_inspector/public/V8InspectorClient.h" | 13 #include "platform/v8_inspector/public/V8InspectorClient.h" |
| 14 |
13 #include <v8-profiler.h> | 15 #include <v8-profiler.h> |
14 #include <v8-version.h> | 16 #include <v8-version.h> |
15 | 17 |
16 namespace v8_inspector { | 18 namespace v8_inspector { |
17 | 19 |
18 namespace { | 20 namespace { |
19 | 21 |
20 namespace HeapProfilerAgentState { | 22 namespace HeapProfilerAgentState { |
21 static const char heapProfilerEnabled[] = "heapProfilerEnabled"; | 23 static const char heapProfilerEnabled[] = "heapProfilerEnabled"; |
22 static const char heapObjectsTrackingEnabled[] = "heapObjectsTrackingEnabled"; | 24 static const char heapObjectsTrackingEnabled[] = "heapObjectsTrackingEnabled"; |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 284 } |
283 | 285 |
284 m_session->addInspectedObject(wrapUnique(new InspectableHeapObject(id))); | 286 m_session->addInspectedObject(wrapUnique(new InspectableHeapObject(id))); |
285 } | 287 } |
286 | 288 |
287 void V8HeapProfilerAgentImpl::getHeapObjectId(ErrorString* errorString, const St
ring16& objectId, String16* heapSnapshotObjectId) | 289 void V8HeapProfilerAgentImpl::getHeapObjectId(ErrorString* errorString, const St
ring16& objectId, String16* heapSnapshotObjectId) |
288 { | 290 { |
289 v8::HandleScope handles(m_isolate); | 291 v8::HandleScope handles(m_isolate); |
290 v8::Local<v8::Value> value; | 292 v8::Local<v8::Value> value; |
291 v8::Local<v8::Context> context; | 293 v8::Local<v8::Context> context; |
292 if (!m_session->unwrapObject(errorString, toStringView(objectId), &value, &c
ontext, nullptr) || value->IsUndefined()) | 294 if (!m_session->unwrapObject(errorString, objectId, &value, &context, nullpt
r) || value->IsUndefined()) |
293 return; | 295 return; |
294 | 296 |
295 v8::SnapshotObjectId id = m_isolate->GetHeapProfiler()->GetObjectId(value); | 297 v8::SnapshotObjectId id = m_isolate->GetHeapProfiler()->GetObjectId(value); |
296 *heapSnapshotObjectId = String16::fromInteger(id); | 298 *heapSnapshotObjectId = String16::fromInteger(id); |
297 } | 299 } |
298 | 300 |
299 void V8HeapProfilerAgentImpl::requestHeapStatsUpdate() | 301 void V8HeapProfilerAgentImpl::requestHeapStatsUpdate() |
300 { | 302 { |
301 HeapStatsStream stream(&m_frontend); | 303 HeapStatsStream stream(&m_frontend); |
302 v8::SnapshotObjectId lastSeenObjectId = m_isolate->GetHeapProfiler()->GetHea
pStats(&stream); | 304 v8::SnapshotObjectId lastSeenObjectId = m_isolate->GetHeapProfiler()->GetHea
pStats(&stream); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 *errorString = "Cannot access v8 sampled heap profile."; | 393 *errorString = "Cannot access v8 sampled heap profile."; |
392 return; | 394 return; |
393 } | 395 } |
394 v8::AllocationProfile::Node* root = v8Profile->GetRootNode(); | 396 v8::AllocationProfile::Node* root = v8Profile->GetRootNode(); |
395 *profile = protocol::HeapProfiler::SamplingHeapProfile::create() | 397 *profile = protocol::HeapProfiler::SamplingHeapProfile::create() |
396 .setHead(buildSampingHeapProfileNode(root)).build(); | 398 .setHead(buildSampingHeapProfileNode(root)).build(); |
397 #endif | 399 #endif |
398 } | 400 } |
399 | 401 |
400 } // namespace v8_inspector | 402 } // namespace v8_inspector |
OLD | NEW |