-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reviewed By: mhorowitz Differential Revision: D6051880 fbshipit-source-id: 0ce4bbed9ba8579033ee5397ff6c0975b6886fb1
- Loading branch information
1 parent
9877c08
commit f3b117a
Showing
5 changed files
with
90 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
#include "ReactMarker.h" | ||
#include <mutex> | ||
#include <cxxreact/Platform.h> | ||
#include <jschelpers/JSCHelpers.h> | ||
#include <fb/fbjni.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
void JReactMarker::setLogPerfMarkerIfNeeded() { | ||
static std::once_flag flag {}; | ||
std::call_once(flag, [](){ | ||
ReactMarker::logTaggedMarker = JReactMarker::logPerfMarker; | ||
}); | ||
} | ||
|
||
void JReactMarker::logMarker(const std::string& marker) { | ||
static auto cls = javaClassStatic(); | ||
static auto meth = cls->getStaticMethod<void(std::string)>("logMarker"); | ||
meth(cls, marker); | ||
} | ||
|
||
void JReactMarker::logMarker(const std::string& marker, const std::string& tag) { | ||
static auto cls = javaClassStatic(); | ||
static auto meth = cls->getStaticMethod<void(std::string, std::string)>("logMarker"); | ||
meth(cls, marker, tag); | ||
} | ||
|
||
void JReactMarker::logPerfMarker(const ReactMarker::ReactMarkerId markerId, const char* tag) { | ||
switch (markerId) { | ||
case ReactMarker::RUN_JS_BUNDLE_START: | ||
JReactMarker::logMarker("RUN_JS_BUNDLE_START", tag); | ||
break; | ||
case ReactMarker::RUN_JS_BUNDLE_STOP: | ||
JReactMarker::logMarker("RUN_JS_BUNDLE_END", tag); | ||
break; | ||
case ReactMarker::CREATE_REACT_CONTEXT_STOP: | ||
JReactMarker::logMarker("CREATE_REACT_CONTEXT_END"); | ||
break; | ||
case ReactMarker::JS_BUNDLE_STRING_CONVERT_START: | ||
JReactMarker::logMarker("loadApplicationScript_startStringConvert"); | ||
break; | ||
case ReactMarker::JS_BUNDLE_STRING_CONVERT_STOP: | ||
JReactMarker::logMarker("loadApplicationScript_endStringConvert"); | ||
break; | ||
case ReactMarker::NATIVE_MODULE_SETUP_START: | ||
JReactMarker::logMarker("NATIVE_MODULE_SETUP_START", tag); | ||
break; | ||
case ReactMarker::NATIVE_MODULE_SETUP_STOP: | ||
JReactMarker::logMarker("NATIVE_MODULE_SETUP_END", tag); | ||
break; | ||
case ReactMarker::NATIVE_REQUIRE_START: | ||
case ReactMarker::NATIVE_REQUIRE_STOP: | ||
// These are not used on Android. | ||
break; | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <fb/fbjni.h> | ||
#include <cxxreact/Platform.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
class JReactMarker : public facebook::jni::JavaClass<JReactMarker> { | ||
public: | ||
static constexpr auto kJavaDescriptor = "Lcom/facebook/react/bridge/ReactMarker;"; | ||
static void setLogPerfMarkerIfNeeded(); | ||
|
||
private: | ||
static void logMarker(const std::string& marker); | ||
static void logMarker(const std::string& marker, const std::string& tag); | ||
static void logPerfMarker(const ReactMarker::ReactMarkerId markerId, const char* tag); | ||
}; | ||
|
||
} | ||
} |