Summary: `/*` is the standard throughout open source code. For example, Firefox uses single /*: https://hg.mozilla.org/mozilla-central/file/21d22b2f541258d3d1cf96c7ba5ad73e96e616b5/gfx/ipc/CompositorWidgetVsyncObserver.cpp#l3 In addition, Rust considers `/**` to be a doc comment (similar to Javadoc) and having such a comment at the beginning of the file causes `rustc` to barf. Note that some JavaScript tooling requires `/**`. This is OK since JavaScript files were not covered by the linter in the first place, but it would be good to have that tooling fixed too. Reviewed By: zertosh Differential Revision: D15640366 fbshipit-source-id: b4ed4599071516364d6109720750d6a43304c089
81 lines
2.0 KiB
C++
81 lines
2.0 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the LICENSE
|
|
* file in the root directory of this source tree.
|
|
*/
|
|
#include "FlipperState.h"
|
|
#include "FlipperStateUpdateListener.h"
|
|
#include "FlipperStep.h"
|
|
#include <vector>
|
|
|
|
#if FLIPPER_DEBUG_LOG
|
|
#include "Log.h"
|
|
#endif
|
|
|
|
using namespace facebook::flipper;
|
|
|
|
/* Class responsible for collecting state updates and combining them into a
|
|
* view of the current state of the flipper client. */
|
|
|
|
FlipperState::FlipperState() : logs("") {}
|
|
void FlipperState::setUpdateListener(
|
|
std::shared_ptr<FlipperStateUpdateListener> listener) {
|
|
mListener = listener;
|
|
}
|
|
|
|
void FlipperState::started(std::string step) {
|
|
#if FLIPPER_DEBUG_LOG
|
|
log("[started] " + step);
|
|
#endif
|
|
if (stateMap.find(step) == stateMap.end()) {
|
|
insertOrder.push_back(step);
|
|
}
|
|
stateMap[step] = State::in_progress;
|
|
if (mListener) {
|
|
mListener->onUpdate();
|
|
}
|
|
}
|
|
|
|
void FlipperState::success(std::string step) {
|
|
#if FLIPPER_DEBUG_LOG
|
|
log("[finished] " + step);
|
|
#endif
|
|
logs = logs + "[Success] " + step + "\n";
|
|
stateMap[step] = State::success;
|
|
if (mListener) {
|
|
mListener->onUpdate();
|
|
}
|
|
}
|
|
|
|
void FlipperState::failed(std::string step, std::string errorMessage) {
|
|
#if FLIPPER_DEBUG_LOG
|
|
log("[failed] " + step);
|
|
#endif
|
|
logs = logs + "[Failed] " + step + ": " + errorMessage + "\n";
|
|
stateMap[step] = State::failed;
|
|
if (mListener) {
|
|
mListener->onUpdate();
|
|
}
|
|
}
|
|
|
|
// TODO: Currently returns string, but should really provide a better
|
|
// representation of the current state so the UI can show it in a more intuitive
|
|
// way
|
|
std::string FlipperState::getState() {
|
|
return logs;
|
|
}
|
|
|
|
std::vector<StateElement> FlipperState::getStateElements() {
|
|
std::vector<StateElement> v;
|
|
for (auto stepName : insertOrder) {
|
|
v.push_back(StateElement(stepName, stateMap[stepName]));
|
|
}
|
|
return v;
|
|
}
|
|
|
|
std::shared_ptr<FlipperStep> FlipperState::start(std::string step_name) {
|
|
started(step_name);
|
|
return std::make_shared<FlipperStep>(step_name, this);
|
|
}
|