diff --git a/sky/engine/bindings/dart_ui.cc b/sky/engine/bindings/dart_ui.cc index e113ef746fdf8e58a96b9e7eb78984eba7a8fc59..429589dc449ea1c247ba8484231119b86d1dfa96 100644 --- a/sky/engine/bindings/dart_ui.cc +++ b/sky/engine/bindings/dart_ui.cc @@ -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( diff --git a/sky/engine/core/core.gni b/sky/engine/core/core.gni index bc409ee49c7264e5d613546fbcfa312cec7eb0a0..47c76cafbd1072eba99164f1cfcfe71e87e37a9d 100644 --- a/sky/engine/core/core.gni +++ b/sky/engine/core/core.gni @@ -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", diff --git a/sky/engine/core/dart/tracing.dart b/sky/engine/core/dart/tracing.dart new file mode 100644 index 0000000000000000000000000000000000000000..983c79c6f87f842990387d62d1152bf67bc8b2df --- /dev/null +++ b/sky/engine/core/dart/tracing.dart @@ -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(); diff --git a/sky/engine/core/dart/window.dart b/sky/engine/core/dart/window.dart index b6e52d48662352b5365f16b10e7a70f7c33d06f0..5d42f1aaf30903c2db8aeccdb64e73407dde5641 100644 --- a/sky/engine/core/dart/window.dart +++ b/sky/engine/core/dart/window.dart @@ -38,4 +38,3 @@ class Window { } final Window window = new Window._(); -final Tracing tracing = new Tracing(); diff --git a/sky/engine/core/tracing/tracing.cc b/sky/engine/core/tracing/tracing.cc new file mode 100644 index 0000000000000000000000000000000000000000..0e2da075a30bbb056821bf3d7d04093ad44ade94 --- /dev/null +++ b/sky/engine/core/tracing/tracing.cc @@ -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::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::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 diff --git a/sky/engine/core/tracing/tracing.h b/sky/engine/core/tracing/tracing.h new file mode 100644 index 0000000000000000000000000000000000000000..b50db9f5578e073e5102e0acdf1916aa71df6a91 --- /dev/null +++ b/sky/engine/core/tracing/tracing.h @@ -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_ diff --git a/sky/engine/core/view/Tracing.cpp b/sky/engine/core/view/Tracing.cpp deleted file mode 100644 index b64847276684967f23aa1ea2e9a57b38fb7cffa4..0000000000000000000000000000000000000000 --- a/sky/engine/core/view/Tracing.cpp +++ /dev/null @@ -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 diff --git a/sky/engine/core/view/Tracing.h b/sky/engine/core/view/Tracing.h deleted file mode 100644 index d7acc25b27baa35da9d700dfd28532f24290f2e2..0000000000000000000000000000000000000000 --- a/sky/engine/core/view/Tracing.h +++ /dev/null @@ -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, public DartWrappable { - DEFINE_WRAPPERTYPEINFO(); -public: - ~Tracing() override; - static PassRefPtr 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_ diff --git a/sky/engine/core/view/Tracing.idl b/sky/engine/core/view/Tracing.idl deleted file mode 100644 index 1e2a417db5525091c215bb61fe11b79786bbbc28..0000000000000000000000000000000000000000 --- a/sky/engine/core/view/Tracing.idl +++ /dev/null @@ -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); -};