| 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/V8Debugger.h" | 8 #include "platform/v8_inspector/V8Debugger.h" |
| 9 #include "platform/v8_inspector/V8InspectorImpl.h" | 9 #include "platform/v8_inspector/V8InspectorImpl.h" |
| 10 #include "platform/v8_inspector/V8InspectorSessionImpl.h" | 10 #include "platform/v8_inspector/V8InspectorSessionImpl.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 return; | 230 return; |
| 231 } | 231 } |
| 232 HeapSnapshotOutputStream stream(&m_frontend); | 232 HeapSnapshotOutputStream stream(&m_frontend); |
| 233 snapshot->Serialize(&stream); | 233 snapshot->Serialize(&stream); |
| 234 const_cast<v8::HeapSnapshot*>(snapshot)->Delete(); | 234 const_cast<v8::HeapSnapshot*>(snapshot)->Delete(); |
| 235 } | 235 } |
| 236 | 236 |
| 237 void V8HeapProfilerAgentImpl::getObjectByHeapObjectId(ErrorString* error, const
String16& heapSnapshotObjectId, const protocol::Maybe<String16>& objectGroup, st
d::unique_ptr<protocol::Runtime::RemoteObject>* result) | 237 void V8HeapProfilerAgentImpl::getObjectByHeapObjectId(ErrorString* error, const
String16& heapSnapshotObjectId, const protocol::Maybe<String16>& objectGroup, st
d::unique_ptr<protocol::Runtime::RemoteObject>* result) |
| 238 { | 238 { |
| 239 bool ok; | 239 bool ok; |
| 240 int id = heapSnapshotObjectId.toInt(&ok); | 240 int id = heapSnapshotObjectId.toInteger(&ok); |
| 241 if (!ok) { | 241 if (!ok) { |
| 242 *error = "Invalid heap snapshot object id"; | 242 *error = "Invalid heap snapshot object id"; |
| 243 return; | 243 return; |
| 244 } | 244 } |
| 245 | 245 |
| 246 v8::HandleScope handles(m_isolate); | 246 v8::HandleScope handles(m_isolate); |
| 247 v8::Local<v8::Object> heapObject = objectByHeapObjectId(m_isolate, id); | 247 v8::Local<v8::Object> heapObject = objectByHeapObjectId(m_isolate, id); |
| 248 if (heapObject.IsEmpty()) { | 248 if (heapObject.IsEmpty()) { |
| 249 *error = "Object is not available"; | 249 *error = "Object is not available"; |
| 250 return; | 250 return; |
| 251 } | 251 } |
| 252 | 252 |
| 253 if (!m_session->inspector()->client()->isInspectableHeapObject(heapObject))
{ | 253 if (!m_session->inspector()->client()->isInspectableHeapObject(heapObject))
{ |
| 254 *error = "Object is not available"; | 254 *error = "Object is not available"; |
| 255 return; | 255 return; |
| 256 } | 256 } |
| 257 | 257 |
| 258 *result = m_session->wrapObject(heapObject->CreationContext(), heapObject, o
bjectGroup.fromMaybe(""), false); | 258 *result = m_session->wrapObject(heapObject->CreationContext(), heapObject, o
bjectGroup.fromMaybe(""), false); |
| 259 if (!result) | 259 if (!result) |
| 260 *error = "Object is not available"; | 260 *error = "Object is not available"; |
| 261 } | 261 } |
| 262 | 262 |
| 263 void V8HeapProfilerAgentImpl::addInspectedHeapObject(ErrorString* errorString, c
onst String16& inspectedHeapObjectId) | 263 void V8HeapProfilerAgentImpl::addInspectedHeapObject(ErrorString* errorString, c
onst String16& inspectedHeapObjectId) |
| 264 { | 264 { |
| 265 bool ok; | 265 bool ok; |
| 266 int id = inspectedHeapObjectId.toInt(&ok); | 266 int id = inspectedHeapObjectId.toInteger(&ok); |
| 267 if (!ok) { | 267 if (!ok) { |
| 268 *errorString = "Invalid heap snapshot object id"; | 268 *errorString = "Invalid heap snapshot object id"; |
| 269 return; | 269 return; |
| 270 } | 270 } |
| 271 | 271 |
| 272 v8::HandleScope handles(m_isolate); | 272 v8::HandleScope handles(m_isolate); |
| 273 v8::Local<v8::Object> heapObject = objectByHeapObjectId(m_isolate, id); | 273 v8::Local<v8::Object> heapObject = objectByHeapObjectId(m_isolate, id); |
| 274 if (heapObject.IsEmpty()) { | 274 if (heapObject.IsEmpty()) { |
| 275 *errorString = "Object is not available"; | 275 *errorString = "Object is not available"; |
| 276 return; | 276 return; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 *errorString = "Cannot access v8 sampled heap profile."; | 392 *errorString = "Cannot access v8 sampled heap profile."; |
| 393 return; | 393 return; |
| 394 } | 394 } |
| 395 v8::AllocationProfile::Node* root = v8Profile->GetRootNode(); | 395 v8::AllocationProfile::Node* root = v8Profile->GetRootNode(); |
| 396 *profile = protocol::HeapProfiler::SamplingHeapProfile::create() | 396 *profile = protocol::HeapProfiler::SamplingHeapProfile::create() |
| 397 .setHead(buildSampingHeapProfileNode(root)).build(); | 397 .setHead(buildSampingHeapProfileNode(root)).build(); |
| 398 #endif | 398 #endif |
| 399 } | 399 } |
| 400 | 400 |
| 401 } // namespace blink | 401 } // namespace blink |
| OLD | NEW |