mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This caused us to lose our gn check certification. :( Turns out gn check was just ignoring all the header paths it didn't understand and so gn check passing for sky wasn't meaning much. I tried to straighten out some of the mess in this CL, but its going to take several more rounds of massaging before gn check passes again. On the bright side (almost) all of our headers are absolute now. Turns out my script (attached to the bug) didn't notice ../ includes but I'll fix that in the next patch. R=abarth@chromium.org BUG=435361 Review URL: https://codereview.chromium.org/746023002
143 lines
3.0 KiB
C++
143 lines
3.0 KiB
C++
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "sky/engine/config.h"
|
|
|
|
#include "sky/engine/platform/TracedValue.h"
|
|
|
|
#include "sky/engine/platform/JSONValues.h"
|
|
|
|
namespace blink {
|
|
|
|
namespace {
|
|
|
|
String threadSafeCopy(const String& string)
|
|
{
|
|
RefPtr<StringImpl> copy(string.impl());
|
|
if (string.isSafeToSendToAnotherThread())
|
|
return string;
|
|
return string.isolatedCopy();
|
|
}
|
|
|
|
}
|
|
|
|
PassRefPtr<TracedValue> TracedValue::create()
|
|
{
|
|
return adoptRef(new TracedValue());
|
|
}
|
|
|
|
TracedValue::TracedValue()
|
|
{
|
|
m_stack.append(JSONObject::create());
|
|
}
|
|
|
|
TracedValue::~TracedValue()
|
|
{
|
|
ASSERT(m_stack.size() == 1);
|
|
}
|
|
|
|
void TracedValue::setInteger(const char* name, int value)
|
|
{
|
|
currentDictionary()->setNumber(name, value);
|
|
}
|
|
|
|
void TracedValue::setDouble(const char* name, double value)
|
|
{
|
|
currentDictionary()->setNumber(name, value);
|
|
}
|
|
|
|
void TracedValue::setBoolean(const char* name, bool value)
|
|
{
|
|
currentDictionary()->setBoolean(name, value);
|
|
}
|
|
|
|
void TracedValue::setString(const char* name, const String& value)
|
|
{
|
|
currentDictionary()->setString(name, threadSafeCopy(value));
|
|
}
|
|
|
|
void TracedValue::beginDictionary(const char* name)
|
|
{
|
|
RefPtr<JSONObject> dictionary = JSONObject::create();
|
|
currentDictionary()->setObject(name, dictionary);
|
|
m_stack.append(dictionary);
|
|
}
|
|
|
|
void TracedValue::beginArray(const char* name)
|
|
{
|
|
RefPtr<JSONArray> array = JSONArray::create();
|
|
currentDictionary()->setArray(name, array);
|
|
m_stack.append(array);
|
|
}
|
|
|
|
void TracedValue::endDictionary()
|
|
{
|
|
ASSERT(m_stack.size() > 1);
|
|
ASSERT(currentDictionary());
|
|
m_stack.removeLast();
|
|
}
|
|
|
|
void TracedValue::pushInteger(int value)
|
|
{
|
|
currentArray()->pushInt(value);
|
|
}
|
|
|
|
void TracedValue::pushDouble(double value)
|
|
{
|
|
currentArray()->pushNumber(value);
|
|
}
|
|
|
|
void TracedValue::pushBoolean(bool value)
|
|
{
|
|
currentArray()->pushBoolean(value);
|
|
}
|
|
|
|
void TracedValue::pushString(const String& value)
|
|
{
|
|
currentArray()->pushString(threadSafeCopy(value));
|
|
}
|
|
|
|
void TracedValue::beginArray()
|
|
{
|
|
RefPtr<JSONArray> array = JSONArray::create();
|
|
currentArray()->pushArray(array);
|
|
m_stack.append(array);
|
|
}
|
|
|
|
void TracedValue::beginDictionary()
|
|
{
|
|
RefPtr<JSONObject> dictionary = JSONObject::create();
|
|
currentArray()->pushObject(dictionary);
|
|
m_stack.append(dictionary);
|
|
}
|
|
|
|
void TracedValue::endArray()
|
|
{
|
|
ASSERT(m_stack.size() > 1);
|
|
ASSERT(currentArray());
|
|
m_stack.removeLast();
|
|
}
|
|
|
|
String TracedValue::asTraceFormat() const
|
|
{
|
|
ASSERT(m_stack.size() == 1);
|
|
return m_stack.first()->toJSONString();
|
|
}
|
|
|
|
JSONObject* TracedValue::currentDictionary() const
|
|
{
|
|
ASSERT(!m_stack.isEmpty());
|
|
ASSERT(m_stack.last()->type() == JSONValue::TypeObject);
|
|
return static_cast<JSONObject*>(m_stack.last().get());
|
|
}
|
|
|
|
JSONArray* TracedValue::currentArray() const
|
|
{
|
|
ASSERT(!m_stack.isEmpty());
|
|
ASSERT(m_stack.last()->type() == JSONValue::TypeArray);
|
|
return static_cast<JSONArray*>(m_stack.last().get());
|
|
}
|
|
|
|
}
|