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 8c5ffa321dbdf5adff6e2195b2dd66c6589fe4cd..d5301debe5fe95625e79dd7e57f4dfb1dfec0455 100644 |
| --- a/third_party/WebKit/Source/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp |
| +++ b/third_party/WebKit/Source/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp |
| @@ -22,21 +22,15 @@ static const char samplingHeapProfilerEnabled[] = "samplingHeapProfilerEnabled"; |
| namespace { |
| -bool asBool(const bool* value) |
| -{ |
| - return value && *value; |
| -} |
| - |
| class HeapSnapshotProgress final : public v8::ActivityControl { |
| public: |
| HeapSnapshotProgress(protocol::Frontend::HeapProfiler* frontend) |
| : m_frontend(frontend) { } |
| ControlOption ReportProgressValue(int done, int total) override |
| { |
| - m_frontend->reportHeapSnapshotProgress(done, total, nullptr); |
| + m_frontend->reportHeapSnapshotProgress(done, total, protocol::TypeBuilder::OptionalValue<bool>()); |
|
dgozman
2016/02/22 23:57:36
We could use default parameters to simplify such c
|
| if (done >= total) { |
| - const bool finished = true; |
| - m_frontend->reportHeapSnapshotProgress(total, total, &finished); |
| + m_frontend->reportHeapSnapshotProgress(total, total, protocol::TypeBuilder::OptionalValue<bool>(true)); |
| } |
| m_frontend->flush(); |
| return kContinue; |
| @@ -120,7 +114,7 @@ public: |
| WriteResult WriteHeapStatsChunk(v8::HeapStatsUpdate* updateData, int count) override |
| { |
| ASSERT(count > 0); |
| - RefPtr<protocol::TypeBuilder::Array<int>> statsDiff = protocol::TypeBuilder::Array<int>::create(); |
| + OwnPtr<protocol::TypeBuilder::Array<int>> statsDiff = protocol::TypeBuilder::Array<int>::create(); |
| for (int i = 0; i < count; ++i) { |
| statsDiff->addItem(updateData[i].index); |
| statsDiff->addItem(updateData[i].count); |
| @@ -176,15 +170,15 @@ void V8HeapProfilerAgentImpl::collectGarbage(ErrorString*) |
| m_isolate->LowMemoryNotification(); |
| } |
| -void V8HeapProfilerAgentImpl::startTrackingHeapObjects(ErrorString*, const bool* trackAllocations) |
| +void V8HeapProfilerAgentImpl::startTrackingHeapObjects(ErrorString*, const protocol::TypeBuilder::OptionalValue<bool>& trackAllocations) |
| { |
| m_state->setBoolean(HeapProfilerAgentState::heapObjectsTrackingEnabled, true); |
| - bool allocationTrackingEnabled = asBool(trackAllocations); |
| + bool allocationTrackingEnabled = trackAllocations.get(false); |
| m_state->setBoolean(HeapProfilerAgentState::allocationTrackingEnabled, allocationTrackingEnabled); |
| startTrackingHeapObjectsInternal(allocationTrackingEnabled); |
| } |
| -void V8HeapProfilerAgentImpl::stopTrackingHeapObjects(ErrorString* error, const bool* reportProgress) |
| +void V8HeapProfilerAgentImpl::stopTrackingHeapObjects(ErrorString* error, const protocol::TypeBuilder::OptionalValue<bool>& reportProgress) |
| { |
| requestHeapStatsUpdate(); |
| takeHeapSnapshot(error, reportProgress); |
| @@ -208,7 +202,7 @@ void V8HeapProfilerAgentImpl::disable(ErrorString* error) |
| m_state->setBoolean(HeapProfilerAgentState::heapProfilerEnabled, false); |
| } |
| -void V8HeapProfilerAgentImpl::takeHeapSnapshot(ErrorString* errorString, const bool* reportProgress) |
| +void V8HeapProfilerAgentImpl::takeHeapSnapshot(ErrorString* errorString, const protocol::TypeBuilder::OptionalValue<bool>& reportProgress) |
| { |
| v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler(); |
| if (!profiler) { |
| @@ -216,7 +210,7 @@ void V8HeapProfilerAgentImpl::takeHeapSnapshot(ErrorString* errorString, const b |
| return; |
| } |
| OwnPtr<HeapSnapshotProgress> progress; |
| - if (asBool(reportProgress)) |
| + if (reportProgress.get(false)) |
| progress = adoptPtr(new HeapSnapshotProgress(m_frontend)); |
| GlobalObjectNameResolver resolver(static_cast<V8RuntimeAgentImpl*>(m_runtimeAgent)); |
| @@ -230,7 +224,7 @@ void V8HeapProfilerAgentImpl::takeHeapSnapshot(ErrorString* errorString, const b |
| const_cast<v8::HeapSnapshot*>(snapshot)->Delete(); |
| } |
| -void V8HeapProfilerAgentImpl::getObjectByHeapObjectId(ErrorString* error, const String& heapSnapshotObjectId, const String* objectGroup, RefPtr<protocol::TypeBuilder::Runtime::RemoteObject>& result) |
| +void V8HeapProfilerAgentImpl::getObjectByHeapObjectId(ErrorString* error, const String& heapSnapshotObjectId, const protocol::TypeBuilder::OptionalValue<String>& objectGroup, OwnPtr<protocol::TypeBuilder::Runtime::RemoteObject>* result) |
| { |
| bool ok; |
| unsigned id = heapSnapshotObjectId.toUInt(&ok); |
| @@ -245,7 +239,7 @@ void V8HeapProfilerAgentImpl::getObjectByHeapObjectId(ErrorString* error, const |
| *error = "Object is not available"; |
| return; |
| } |
| - result = m_runtimeAgent->wrapObject(heapObject->CreationContext(), heapObject, objectGroup ? *objectGroup : ""); |
| + *result = m_runtimeAgent->wrapObject(heapObject->CreationContext(), heapObject, objectGroup.get("")); |
| if (!result) |
| *error = "Object is not available"; |
| } |
| @@ -307,7 +301,7 @@ void V8HeapProfilerAgentImpl::startSampling(ErrorString* errorString) |
| } |
| namespace { |
| -PassRefPtr<protocol::TypeBuilder::HeapProfiler::SamplingHeapProfileNode> buildSampingHeapProfileNode(const v8::AllocationProfile::Node* node) |
| +PassOwnPtr<protocol::TypeBuilder::HeapProfiler::SamplingHeapProfileNode> buildSampingHeapProfileNode(const v8::AllocationProfile::Node* node) |
| { |
| auto children = protocol::TypeBuilder::Array<protocol::TypeBuilder::HeapProfiler::SamplingHeapProfileNode>::create(); |
| for (const auto* child : node->children) |
| @@ -315,19 +309,19 @@ PassRefPtr<protocol::TypeBuilder::HeapProfiler::SamplingHeapProfileNode> buildSa |
| size_t totalSize = 0; |
| for (const auto& allocation : node->allocations) |
| totalSize += allocation.size * allocation.count; |
| - RefPtr<protocol::TypeBuilder::HeapProfiler::SamplingHeapProfileNode> result = protocol::TypeBuilder::HeapProfiler::SamplingHeapProfileNode::create() |
| + OwnPtr<protocol::TypeBuilder::HeapProfiler::SamplingHeapProfileNode> result = protocol::TypeBuilder::HeapProfiler::SamplingHeapProfileNode::create() |
| .setFunctionName(toWTFString(node->name)) |
| .setScriptId(String::number(node->script_id)) |
| .setUrl(toWTFString(node->script_name)) |
| .setLineNumber(node->line_number) |
| .setColumnNumber(node->column_number) |
| .setTotalSize(totalSize) |
| - .setChildren(children); |
| + .setChildren(children).build(); |
| return result.release(); |
| } |
| } // namespace |
| -void V8HeapProfilerAgentImpl::stopSampling(ErrorString* errorString, RefPtr<protocol::TypeBuilder::HeapProfiler::SamplingHeapProfile>& profile) |
| +void V8HeapProfilerAgentImpl::stopSampling(ErrorString* errorString, OwnPtr<protocol::TypeBuilder::HeapProfiler::SamplingHeapProfile>* profile) |
| { |
| v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler(); |
| if (!profiler) { |
| @@ -343,8 +337,8 @@ void V8HeapProfilerAgentImpl::stopSampling(ErrorString* errorString, RefPtr<prot |
| return; |
| } |
| v8::AllocationProfile::Node* root = v8Profile->GetRootNode(); |
| - profile = protocol::TypeBuilder::HeapProfiler::SamplingHeapProfile::create() |
| - .setHead(buildSampingHeapProfileNode(root)); |
| + *profile = protocol::TypeBuilder::HeapProfiler::SamplingHeapProfile::create() |
| + .setHead(buildSampingHeapProfileNode(root)).build(); |
| } |
| } // namespace blink |