Chromium Code Reviews| Index: third_party/WebKit/Source/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp |
| diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp |
| index 683a2f33077951998a931494ee1d1b55e5f41130..c7aa627a0403a0a073092c000b714ff902b84477 100644 |
| --- a/third_party/WebKit/Source/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp |
| +++ b/third_party/WebKit/Source/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp |
| @@ -51,13 +51,20 @@ public: |
| InjectedScript* injectedScript = m_runtimeAgent->injectedScriptManager()->findInjectedScript(contextId); |
| if (!injectedScript) |
| return ""; |
| - String16 name = injectedScript->origin().latin1Data(); |
| - m_strings.append(name); |
| - return reinterpret_cast<const char *>(name.characters8()); |
| + String16 name = injectedScript->origin(); |
| + size_t offset = m_strings.size(); |
| + size_t length = name.length(); |
| + m_strings.resize(offset + length + 1); |
|
dgozman
2016/03/10 18:59:47
This call invalidates previously returned char*
|
| + for (size_t i = 0; i < length; ++i) { |
| + UChar ch = name[i]; |
| + m_strings[offset + i] = ch > 0xff ? '?' : static_cast<char>(ch); |
| + } |
| + m_strings[offset + length] = '\0'; |
| + return &*m_strings.begin() + offset; |
| } |
| private: |
| - protocol::Vector<String16> m_strings; |
| + protocol::Vector<char> m_strings; |
| V8RuntimeAgentImpl* m_runtimeAgent; |
| }; |
| @@ -77,7 +84,7 @@ private: |
| protocol::Frontend::HeapProfiler* m_frontend; |
| }; |
| -v8::Local<v8::Object> objectByHeapObjectId(v8::Isolate* isolate, unsigned id) |
| +v8::Local<v8::Object> objectByHeapObjectId(v8::Isolate* isolate, int id) |
| { |
| v8::HeapProfiler* profiler = isolate->GetHeapProfiler(); |
| v8::Local<v8::Value> value = profiler->FindObjectById(id); |
| @@ -88,13 +95,13 @@ v8::Local<v8::Object> objectByHeapObjectId(v8::Isolate* isolate, unsigned id) |
| class InspectableHeapObject final : public V8RuntimeAgent::Inspectable { |
| public: |
| - explicit InspectableHeapObject(unsigned heapObjectId) : m_heapObjectId(heapObjectId) { } |
| + explicit InspectableHeapObject(int heapObjectId) : m_heapObjectId(heapObjectId) { } |
| v8::Local<v8::Value> get(v8::Local<v8::Context> context) override |
| { |
| return objectByHeapObjectId(context->GetIsolate(), m_heapObjectId); |
| } |
| private: |
| - unsigned m_heapObjectId; |
| + int m_heapObjectId; |
| }; |
| class HeapStatsStream final : public v8::OutputStream { |
| @@ -228,7 +235,7 @@ void V8HeapProfilerAgentImpl::takeHeapSnapshot(ErrorString* errorString, const p |
| void V8HeapProfilerAgentImpl::getObjectByHeapObjectId(ErrorString* error, const String16& heapSnapshotObjectId, const protocol::Maybe<String16>& objectGroup, OwnPtr<protocol::Runtime::RemoteObject>* result) |
| { |
| bool ok; |
| - unsigned id = heapSnapshotObjectId.toUInt(&ok); |
| + int id = heapSnapshotObjectId.toInt(&ok); |
| if (!ok) { |
| *error = "Invalid heap snapshot object id"; |
| return; |
| @@ -248,7 +255,7 @@ void V8HeapProfilerAgentImpl::getObjectByHeapObjectId(ErrorString* error, const |
| void V8HeapProfilerAgentImpl::addInspectedHeapObject(ErrorString* errorString, const String16& inspectedHeapObjectId) |
| { |
| bool ok; |
| - unsigned id = inspectedHeapObjectId.toUInt(&ok); |
| + int id = inspectedHeapObjectId.toInt(&ok); |
| if (!ok) { |
| *errorString = "Invalid heap snapshot object id"; |
| return; |