Files
react-native/ReactCommon/react/renderer/mounting/TelemetryController.cpp
T
Oleksandr Melnykov 2f5a1e6124 Back out "Pass mutation list to RCTMountingTransactionObserving callbacks"
Summary:
https://fb.workplace.com/groups/fbapp.commerce.engsupport/permalink/2074812256012212/

Back out "[react-native][PR] Pass mutation list to RCTMountingTransactionObserving callbacks"

Original commit changeset: f40afc512f2c

Original Phabricator Diff: D35214478 (https://github.com/facebook/react-native/commit/91fc2c00919af98f248b2544f780d63e1056e1af)

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D35825832

fbshipit-source-id: b53b616dca39c84b3a8e8e4cbaa4a45834e53fe3
2022-04-21 16:27:57 -07:00

59 lines
1.6 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "TelemetryController.h"
#include <react/renderer/mounting/MountingCoordinator.h>
namespace facebook {
namespace react {
TelemetryController::TelemetryController(
MountingCoordinator const &mountingCoordinator) noexcept
: mountingCoordinator_(mountingCoordinator) {}
bool TelemetryController::pullTransaction(
std::function<void(MountingTransactionMetadata metadata)> const &willMount,
std::function<void(ShadowViewMutationList const &mutations)> const &doMount,
std::function<void(MountingTransactionMetadata metadata)> const &didMount)
const {
auto optional = mountingCoordinator_.pullTransaction();
if (!optional.has_value()) {
return false;
}
auto transaction = std::move(*optional);
auto surfaceId = transaction.getSurfaceId();
auto number = transaction.getNumber();
auto telemetry = transaction.getTelemetry();
auto numberOfMutations = static_cast<int>(transaction.getMutations().size());
mutex_.lock();
auto compoundTelemetry = compoundTelemetry_;
mutex_.unlock();
willMount({surfaceId, number, telemetry, compoundTelemetry});
telemetry.willMount();
doMount(transaction.getMutations());
telemetry.didMount();
compoundTelemetry.incorporate(telemetry, numberOfMutations);
didMount({surfaceId, number, telemetry, compoundTelemetry});
mutex_.lock();
compoundTelemetry_ = compoundTelemetry;
mutex_.unlock();
return true;
}
} // namespace react
} // namespace facebook