mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Merge pull request #1965 from jason-simmons/idl_tracing
Convert Tracing to stop using the IDL-based bindings
This commit is contained in:
commit
cc030ef888
@ -7,6 +7,7 @@
|
||||
#include "gen/sky/bindings/DartGlobal.h"
|
||||
#include "sky/engine/bindings/dart_runtime_hooks.h"
|
||||
#include "sky/engine/core/painting/painting.h"
|
||||
#include "sky/engine/core/tracing/tracing.h"
|
||||
#include "sky/engine/core/window/window.h"
|
||||
#include "sky/engine/tonic/dart_converter.h"
|
||||
#include "sky/engine/tonic/dart_error.h"
|
||||
@ -40,6 +41,7 @@ void DartUI::InitForIsolate() {
|
||||
DartRuntimeHooks::RegisterNatives(g_natives);
|
||||
Window::RegisterNatives(g_natives);
|
||||
Painting::RegisterNatives(g_natives);
|
||||
Tracing::RegisterNatives(g_natives);
|
||||
}
|
||||
|
||||
DART_CHECK_VALID(Dart_SetNativeResolver(
|
||||
|
||||
@ -244,8 +244,8 @@ sky_core_files = [
|
||||
"text/Paragraph.h",
|
||||
"text/ParagraphBuilder.cpp",
|
||||
"text/ParagraphBuilder.h",
|
||||
"view/Tracing.cpp",
|
||||
"view/Tracing.h",
|
||||
"tracing/tracing.cc",
|
||||
"tracing/tracing.h",
|
||||
"window/window.cc",
|
||||
"window/window.h",
|
||||
]
|
||||
@ -275,7 +275,6 @@ core_idl_files = get_path_info([
|
||||
"painting/Shader.idl",
|
||||
"text/Paragraph.idl",
|
||||
"text/ParagraphBuilder.idl",
|
||||
"view/Tracing.idl",
|
||||
],
|
||||
"abspath")
|
||||
|
||||
@ -285,6 +284,7 @@ core_dart_files = get_path_info([
|
||||
"dart/lerp.dart",
|
||||
"dart/painting.dart",
|
||||
"dart/text.dart",
|
||||
"dart/tracing.dart",
|
||||
"dart/window.dart",
|
||||
"painting/Color.dart",
|
||||
"painting/ColorFilter.dart",
|
||||
|
||||
12
sky/engine/core/dart/tracing.dart
Normal file
12
sky/engine/core/dart/tracing.dart
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright 2015 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.
|
||||
|
||||
part of dart_ui;
|
||||
|
||||
class _Tracing {
|
||||
void begin(String name) native "Tracing_begin";
|
||||
void end(String name) native "Tracing_end";
|
||||
}
|
||||
|
||||
final _Tracing tracing = new _Tracing();
|
||||
@ -38,4 +38,3 @@ class Window {
|
||||
}
|
||||
|
||||
final Window window = new Window._();
|
||||
final Tracing tracing = new Tracing();
|
||||
|
||||
52
sky/engine/core/tracing/tracing.cc
Normal file
52
sky/engine/core/tracing/tracing.cc
Normal file
@ -0,0 +1,52 @@
|
||||
// Copyright 2015 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/core/tracing/tracing.h"
|
||||
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "sky/engine/tonic/dart_converter.h"
|
||||
#include "sky/engine/wtf/text/StringUTF8Adaptor.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
namespace {
|
||||
|
||||
void BeginTracing(Dart_NativeArguments args) {
|
||||
Dart_Handle exception = nullptr;
|
||||
String name = DartConverter<String>::FromArguments(args, 1, exception);
|
||||
if (exception) {
|
||||
Dart_ThrowException(exception);
|
||||
return;
|
||||
}
|
||||
|
||||
StringUTF8Adaptor utf8(name);
|
||||
// TRACE_EVENT_COPY_BEGIN0 needs a c-style null-terminated string.
|
||||
CString cstring(utf8.data(), utf8.length());
|
||||
TRACE_EVENT_COPY_BEGIN0("script", cstring.data());
|
||||
}
|
||||
|
||||
void EndTracing(Dart_NativeArguments args) {
|
||||
Dart_Handle exception = nullptr;
|
||||
String name = DartConverter<String>::FromArguments(args, 1, exception);
|
||||
if (exception) {
|
||||
Dart_ThrowException(exception);
|
||||
return;
|
||||
}
|
||||
|
||||
StringUTF8Adaptor utf8(name);
|
||||
// TRACE_EVENT_COPY_END0 needs a c-style null-terminated string.
|
||||
CString cstring(utf8.data(), utf8.length());
|
||||
TRACE_EVENT_COPY_END0("script", cstring.data());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void Tracing::RegisterNatives(DartLibraryNatives* natives) {
|
||||
natives->Register({
|
||||
{ "Tracing_begin", BeginTracing, 2, true },
|
||||
{ "Tracing_end", EndTracing, 2, true },
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
19
sky/engine/core/tracing/tracing.h
Normal file
19
sky/engine/core/tracing/tracing.h
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2015 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.
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_TRACING_TRACING_H_
|
||||
#define SKY_ENGINE_CORE_TRACING_TRACING_H_
|
||||
|
||||
#include "sky/engine/tonic/dart_library_natives.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class Tracing {
|
||||
public:
|
||||
static void RegisterNatives(DartLibraryNatives* natives);
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_TRACING_TRACING_H_
|
||||
@ -1,36 +0,0 @@
|
||||
// Copyright 2015 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/core/view/Tracing.h"
|
||||
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "sky/engine/wtf/text/StringUTF8Adaptor.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
Tracing::Tracing()
|
||||
{
|
||||
}
|
||||
|
||||
Tracing::~Tracing()
|
||||
{
|
||||
}
|
||||
|
||||
void Tracing::begin(const String& name)
|
||||
{
|
||||
StringUTF8Adaptor utf8(name);
|
||||
// TRACE_EVENT_COPY_BEGIN0 needs a c-style null-terminated string.
|
||||
CString cstring(utf8.data(), utf8.length());
|
||||
TRACE_EVENT_COPY_BEGIN0("script", cstring.data());
|
||||
}
|
||||
|
||||
void Tracing::end(const String& name)
|
||||
{
|
||||
StringUTF8Adaptor utf8(name);
|
||||
// TRACE_EVENT_COPY_END0 needs a c-style null-terminated string.
|
||||
CString cstring(utf8.data(), utf8.length());
|
||||
TRACE_EVENT_COPY_END0("script", cstring.data());
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
@ -1,30 +0,0 @@
|
||||
// Copyright 2015 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.
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_VIEW_TRACING_H_
|
||||
#define SKY_ENGINE_CORE_VIEW_TRACING_H_
|
||||
|
||||
#include "sky/engine/tonic/dart_wrappable.h"
|
||||
#include "sky/engine/wtf/PassRefPtr.h"
|
||||
#include "sky/engine/wtf/RefCounted.h"
|
||||
#include "sky/engine/wtf/text/WTFString.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class Tracing : public RefCounted<Tracing>, public DartWrappable {
|
||||
DEFINE_WRAPPERTYPEINFO();
|
||||
public:
|
||||
~Tracing() override;
|
||||
static PassRefPtr<Tracing> create() { return adoptRef(new Tracing); }
|
||||
|
||||
void begin(const String& name);
|
||||
void end(const String& name);
|
||||
|
||||
private:
|
||||
Tracing();
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_VIEW_TRACING_H_
|
||||
@ -1,10 +0,0 @@
|
||||
// Copyright 2015 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.
|
||||
|
||||
[
|
||||
Constructor()
|
||||
] interface Tracing {
|
||||
void begin(DOMString name);
|
||||
void end(DOMString name);
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user