Rename SonarState* to FlipperState*

Summary: Part of sonar to flipper rename

Reviewed By: passy

Differential Revision: D9919821

fbshipit-source-id: a44a2a04d5463750f884f8bf1328e02d56593e82
This commit is contained in:
John Knox
2018-09-24 05:53:51 -07:00
committed by Facebook Github Bot
parent 1d2793f701
commit c1295b1bc9
13 changed files with 42 additions and 42 deletions

View File

@@ -22,8 +22,8 @@
#include <Flipper/FlipperConnectionManager.h> #include <Flipper/FlipperConnectionManager.h>
#include <Flipper/FlipperConnection.h> #include <Flipper/FlipperConnection.h>
#include <Flipper/FlipperResponder.h> #include <Flipper/FlipperResponder.h>
#include <Flipper/SonarStateUpdateListener.h> #include <Flipper/FlipperStateUpdateListener.h>
#include <Flipper/SonarState.h> #include <Flipper/FlipperState.h>
using namespace facebook; using namespace facebook;
using namespace facebook::flipper; using namespace facebook::flipper;
@@ -222,7 +222,7 @@ class JFlipperStateUpdateListener : public jni::JavaClass<JFlipperStateUpdateLis
} }
}; };
class AndroidFlipperStateUpdateListener : public SonarStateUpdateListener { class AndroidFlipperStateUpdateListener : public FlipperStateUpdateListener {
public: public:
AndroidFlipperStateUpdateListener(jni::alias_ref<JFlipperStateUpdateListener> stateListener); AndroidFlipperStateUpdateListener(jni::alias_ref<JFlipperStateUpdateListener> stateListener);
void onUpdate(); void onUpdate();
@@ -378,7 +378,7 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
private: private:
friend HybridBase; friend HybridBase;
std::shared_ptr<SonarStateUpdateListener> mStateListener = nullptr; std::shared_ptr<FlipperStateUpdateListener> mStateListener = nullptr;
JFlipperClient() {} JFlipperClient() {}
}; };

View File

@@ -1,6 +1,6 @@
#ifdef FB_SONARKIT_ENABLED #ifdef FB_SONARKIT_ENABLED
#include <Flipper/SonarStateUpdateListener.h> #include <Flipper/FlipperStateUpdateListener.h>
#import "FlipperStateUpdateListener.h" #import "FlipperStateUpdateListener.h"
/* /*
@@ -8,7 +8,7 @@
* A SKStateUpdateCPPWrapper instance allows for wrapping an Objective-C object * A SKStateUpdateCPPWrapper instance allows for wrapping an Objective-C object
* and passing it to the pure C++ SonarClient, so it can be triggered when updates occur. * and passing it to the pure C++ SonarClient, so it can be triggered when updates occur.
*/ */
class SKStateUpdateCPPWrapper : public SonarStateUpdateListener { class SKStateUpdateCPPWrapper : public FlipperStateUpdateListener {
public: public:
SKStateUpdateCPPWrapper(id<FlipperStateUpdateListener> delegate_); SKStateUpdateCPPWrapper(id<FlipperStateUpdateListener> delegate_);
void onUpdate(); void onUpdate();

View File

@@ -9,7 +9,7 @@
#include "FlipperClient.h" #include "FlipperClient.h"
#include "FlipperConnectionImpl.h" #include "FlipperConnectionImpl.h"
#include "FlipperResponderImpl.h" #include "FlipperResponderImpl.h"
#include "SonarState.h" #include "FlipperState.h"
#include "SonarStep.h" #include "SonarStep.h"
#include "FlipperConnectionManagerImpl.h" #include "FlipperConnectionManagerImpl.h"
#include "ConnectionContextStore.h" #include "ConnectionContextStore.h"
@@ -29,7 +29,7 @@ static FlipperClient* kInstance;
using folly::dynamic; using folly::dynamic;
void FlipperClient::init(FlipperInitConfig config) { void FlipperClient::init(FlipperInitConfig config) {
auto state = std::make_shared<SonarState>(); auto state = std::make_shared<FlipperState>();
auto context = std::make_shared<ConnectionContextStore>(config.deviceData); auto context = std::make_shared<ConnectionContextStore>(config.deviceData);
kInstance = kInstance =
new FlipperClient(std::make_unique<FlipperConnectionManagerImpl>(std::move(config), state, context), state); new FlipperClient(std::make_unique<FlipperConnectionManagerImpl>(std::move(config), state, context), state);
@@ -40,7 +40,7 @@ FlipperClient* FlipperClient::instance() {
} }
void FlipperClient::setStateListener( void FlipperClient::setStateListener(
std::shared_ptr<SonarStateUpdateListener> stateListener) { std::shared_ptr<FlipperStateUpdateListener> stateListener) {
log("Setting state listener"); log("Setting state listener");
sonarState_->setUpdateListener(stateListener); sonarState_->setUpdateListener(stateListener);
} }

View File

@@ -11,7 +11,7 @@
#include "FlipperConnectionImpl.h" #include "FlipperConnectionImpl.h"
#include "FlipperInitConfig.h" #include "FlipperInitConfig.h"
#include "FlipperPlugin.h" #include "FlipperPlugin.h"
#include "SonarState.h" #include "FlipperState.h"
#include "FlipperConnectionManager.h" #include "FlipperConnectionManager.h"
#include <map> #include <map>
#include <mutex> #include <mutex>
@@ -40,7 +40,7 @@ class FlipperClient : public FlipperConnectionManager::Callbacks {
/** /**
Only public for testing Only public for testing
*/ */
FlipperClient(std::unique_ptr<FlipperConnectionManager> socket, std::shared_ptr<SonarState> state) FlipperClient(std::unique_ptr<FlipperConnectionManager> socket, std::shared_ptr<FlipperState> state)
: socket_(std::move(socket)), sonarState_(state) { : socket_(std::move(socket)), sonarState_(state) {
auto step = sonarState_->start("Create client"); auto step = sonarState_->start("Create client");
socket_->setCallbacks(this); socket_->setCallbacks(this);
@@ -72,7 +72,7 @@ class FlipperClient : public FlipperConnectionManager::Callbacks {
void refreshPlugins(); void refreshPlugins();
void setStateListener( void setStateListener(
std::shared_ptr<SonarStateUpdateListener> stateListener); std::shared_ptr<FlipperStateUpdateListener> stateListener);
std::shared_ptr<FlipperPlugin> getPlugin(const std::string& identifier); std::shared_ptr<FlipperPlugin> getPlugin(const std::string& identifier);
@@ -94,7 +94,7 @@ class FlipperClient : public FlipperConnectionManager::Callbacks {
std::map<std::string, std::shared_ptr<FlipperPlugin>> plugins_; std::map<std::string, std::shared_ptr<FlipperPlugin>> plugins_;
std::map<std::string, std::shared_ptr<FlipperConnectionImpl>> connections_; std::map<std::string, std::shared_ptr<FlipperConnectionImpl>> connections_;
std::mutex mutex_; std::mutex mutex_;
std::shared_ptr<SonarState> sonarState_; std::shared_ptr<FlipperState> sonarState_;
void performAndReportError(const std::function<void()>& func); void performAndReportError(const std::function<void()>& func);
void disconnect(std::shared_ptr<FlipperPlugin> plugin); void disconnect(std::shared_ptr<FlipperPlugin> plugin);

View File

@@ -77,7 +77,7 @@ class Responder : public rsocket::RSocketResponder {
} }
}; };
FlipperConnectionManagerImpl::FlipperConnectionManagerImpl(FlipperInitConfig config, std::shared_ptr<SonarState> state, std::shared_ptr<ConnectionContextStore> contextStore) FlipperConnectionManagerImpl::FlipperConnectionManagerImpl(FlipperInitConfig config, std::shared_ptr<FlipperState> state, std::shared_ptr<ConnectionContextStore> contextStore)
: deviceData_(config.deviceData), sonarState_(state), sonarEventBase_(config.callbackWorker), connectionEventBase_(config.connectionWorker), contextStore_(contextStore) { : deviceData_(config.deviceData), sonarState_(state), sonarEventBase_(config.callbackWorker), connectionEventBase_(config.connectionWorker), contextStore_(contextStore) {
CHECK_THROW(config.callbackWorker, std::invalid_argument); CHECK_THROW(config.callbackWorker, std::invalid_argument);
CHECK_THROW(config.connectionWorker, std::invalid_argument); CHECK_THROW(config.connectionWorker, std::invalid_argument);

View File

@@ -10,7 +10,7 @@
#include "FlipperInitConfig.h" #include "FlipperInitConfig.h"
#include "FlipperConnectionManager.h" #include "FlipperConnectionManager.h"
#include "SonarState.h" #include "FlipperState.h"
#include <folly/Executor.h> #include <folly/Executor.h>
#include <folly/io/async/EventBase.h> #include <folly/io/async/EventBase.h>
#include <rsocket/RSocket.h> #include <rsocket/RSocket.h>
@@ -28,7 +28,7 @@ class FlipperConnectionManagerImpl : public FlipperConnectionManager {
friend Responder; friend Responder;
public: public:
FlipperConnectionManagerImpl(FlipperInitConfig config, std::shared_ptr<SonarState> state, std::shared_ptr<ConnectionContextStore> contextStore); FlipperConnectionManagerImpl(FlipperInitConfig config, std::shared_ptr<FlipperState> state, std::shared_ptr<ConnectionContextStore> contextStore);
~FlipperConnectionManagerImpl(); ~FlipperConnectionManagerImpl();
@@ -48,7 +48,7 @@ class FlipperConnectionManagerImpl : public FlipperConnectionManager {
bool isOpen_ = false; bool isOpen_ = false;
Callbacks* callbacks_; Callbacks* callbacks_;
DeviceData deviceData_; DeviceData deviceData_;
std::shared_ptr<SonarState> sonarState_; std::shared_ptr<FlipperState> sonarState_;
folly::EventBase* sonarEventBase_; folly::EventBase* sonarEventBase_;
folly::EventBase* connectionEventBase_; folly::EventBase* connectionEventBase_;

View File

@@ -5,8 +5,8 @@
* file in the root directory of this source tree. * file in the root directory of this source tree.
* *
*/ */
#include "SonarState.h" #include "FlipperState.h"
#include "SonarStateUpdateListener.h" #include "FlipperStateUpdateListener.h"
#include "SonarStep.h" #include "SonarStep.h"
#include <vector> #include <vector>
@@ -16,13 +16,13 @@ using namespace facebook::flipper;
* view of the current state of the sonar client. */ * view of the current state of the sonar client. */
SonarState::SonarState(): log("") {} FlipperState::FlipperState(): log("") {}
void SonarState::setUpdateListener( void FlipperState::setUpdateListener(
std::shared_ptr<SonarStateUpdateListener> listener) { std::shared_ptr<FlipperStateUpdateListener> listener) {
mListener = listener; mListener = listener;
} }
void SonarState::started(std::string step) { void FlipperState::started(std::string step) {
if (stateMap.find(step) == stateMap.end()) { if (stateMap.find(step) == stateMap.end()) {
insertOrder.push_back(step); insertOrder.push_back(step);
} }
@@ -32,7 +32,7 @@ void SonarState::started(std::string step) {
} }
} }
void SonarState::success(std::string step) { void FlipperState::success(std::string step) {
log = log + "[Success] " + step + "\n"; log = log + "[Success] " + step + "\n";
stateMap[step] = State::success; stateMap[step] = State::success;
if (mListener) { if (mListener) {
@@ -40,7 +40,7 @@ void SonarState::success(std::string step) {
} }
} }
void SonarState::failed(std::string step, std::string errorMessage) { void FlipperState::failed(std::string step, std::string errorMessage) {
log = log + "[Failed] " + step + ": " + errorMessage + "\n"; log = log + "[Failed] " + step + ": " + errorMessage + "\n";
stateMap[step] = State::failed; stateMap[step] = State::failed;
if (mListener) { if (mListener) {
@@ -51,11 +51,11 @@ void SonarState::failed(std::string step, std::string errorMessage) {
// TODO: Currently returns string, but should really provide a better // 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 // representation of the current state so the UI can show it in a more intuitive
// way // way
std::string SonarState::getState() { std::string FlipperState::getState() {
return log; return log;
} }
std::vector<StateElement> SonarState::getStateElements() { std::vector<StateElement> FlipperState::getStateElements() {
std::vector<StateElement> v; std::vector<StateElement> v;
for (auto stepName : insertOrder) { for (auto stepName : insertOrder) {
v.push_back(StateElement(stepName, stateMap[stepName])); v.push_back(StateElement(stepName, stateMap[stepName]));
@@ -63,7 +63,7 @@ std::vector<StateElement> SonarState::getStateElements() {
return v; return v;
} }
std::shared_ptr<SonarStep> SonarState::start(std::string step_name) { std::shared_ptr<SonarStep> FlipperState::start(std::string step_name) {
started(step_name); started(step_name);
return std::make_shared<SonarStep>(step_name, this); return std::make_shared<SonarStep>(step_name, this);
} }

View File

@@ -14,7 +14,7 @@
#include <map> #include <map>
class SonarStep; class SonarStep;
class SonarStateUpdateListener; class FlipperStateUpdateListener;
namespace facebook { namespace facebook {
namespace flipper { namespace flipper {
@@ -31,12 +31,12 @@ public:
} }
} }
class SonarState { class FlipperState {
friend SonarStep; friend SonarStep;
public: public:
SonarState(); FlipperState();
void setUpdateListener(std::shared_ptr<SonarStateUpdateListener>); void setUpdateListener(std::shared_ptr<FlipperStateUpdateListener>);
std::string getState(); std::string getState();
std::vector<facebook::flipper::StateElement> getStateElements(); std::vector<facebook::flipper::StateElement> getStateElements();
@@ -51,7 +51,7 @@ class SonarState {
void failed(std::string, std::string); void failed(std::string, std::string);
void started(std::string); void started(std::string);
std::shared_ptr<SonarStateUpdateListener> mListener = nullptr; std::shared_ptr<FlipperStateUpdateListener> mListener = nullptr;
std::string log; std::string log;
std::vector<std::string> insertOrder; std::vector<std::string> insertOrder;
std::map<std::string, facebook::flipper::State> stateMap; std::map<std::string, facebook::flipper::State> stateMap;

View File

@@ -8,7 +8,7 @@
#pragma once #pragma once
class SonarStateUpdateListener { class FlipperStateUpdateListener {
public: public:
virtual void onUpdate() = 0; virtual void onUpdate() = 0;
}; };

View File

@@ -6,7 +6,7 @@
* *
*/ */
#include "SonarStep.h" #include "SonarStep.h"
#include "SonarState.h" #include "FlipperState.h"
void SonarStep::complete() { void SonarStep::complete() {
isLogged = true; isLogged = true;
@@ -18,7 +18,7 @@ void SonarStep::fail(std::string message) {
state->failed(name, message); state->failed(name, message);
} }
SonarStep::SonarStep(std::string step, SonarState* s) { SonarStep::SonarStep(std::string step, FlipperState* s) {
state = s; state = s;
name = step; name = step;
} }

View File

@@ -10,7 +10,7 @@
#include <string> #include <string>
class SonarState; class FlipperState;
class SonarStep { class SonarStep {
public: public:
@@ -22,11 +22,11 @@ class SonarStep {
// Mark the step as failed, and provide a message. // Mark the step as failed, and provide a message.
void fail(std::string message); void fail(std::string message);
SonarStep(std::string name, SonarState* state); SonarStep(std::string name, FlipperState* state);
~SonarStep(); ~SonarStep();
private: private:
std::string name; std::string name;
bool isLogged = false; bool isLogged = false;
SonarState* state; FlipperState* state;
}; };

View File

@@ -19,7 +19,7 @@ namespace test {
using folly::dynamic; using folly::dynamic;
auto state = std::make_shared<SonarState>(); auto state = std::make_shared<FlipperState>();
TEST(SonarClientTests, testSaneMocks) { TEST(SonarClientTests, testSaneMocks) {
FlipperConnectionManagerMock socket; FlipperConnectionManagerMock socket;

View File

@@ -19,13 +19,13 @@ using folly::EventBase;
class FlipperConnectionManagerImplTerminationTest : public ::testing::Test { class FlipperConnectionManagerImplTerminationTest : public ::testing::Test {
protected: protected:
std::shared_ptr<SonarState> state; std::shared_ptr<FlipperState> state;
std::shared_ptr<ConnectionContextStore> contextStore; std::shared_ptr<ConnectionContextStore> contextStore;
void SetUp() override { void SetUp() override {
// Folly singletons must be registered before they are used. // Folly singletons must be registered before they are used.
// Without this, test fails in phabricator. // Without this, test fails in phabricator.
folly::SingletonVault::singleton()->registrationComplete(); folly::SingletonVault::singleton()->registrationComplete();
state = std::make_shared<SonarState>(); state = std::make_shared<FlipperState>();
contextStore = std::make_shared<ConnectionContextStoreMock>(); contextStore = std::make_shared<ConnectionContextStoreMock>();
} }
}; };