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

View File

@@ -1,6 +1,6 @@
#ifdef FB_SONARKIT_ENABLED
#include <Flipper/SonarStateUpdateListener.h>
#include <Flipper/FlipperStateUpdateListener.h>
#import "FlipperStateUpdateListener.h"
/*
@@ -8,7 +8,7 @@
* 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.
*/
class SKStateUpdateCPPWrapper : public SonarStateUpdateListener {
class SKStateUpdateCPPWrapper : public FlipperStateUpdateListener {
public:
SKStateUpdateCPPWrapper(id<FlipperStateUpdateListener> delegate_);
void onUpdate();

View File

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

View File

@@ -11,7 +11,7 @@
#include "FlipperConnectionImpl.h"
#include "FlipperInitConfig.h"
#include "FlipperPlugin.h"
#include "SonarState.h"
#include "FlipperState.h"
#include "FlipperConnectionManager.h"
#include <map>
#include <mutex>
@@ -40,7 +40,7 @@ class FlipperClient : public FlipperConnectionManager::Callbacks {
/**
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) {
auto step = sonarState_->start("Create client");
socket_->setCallbacks(this);
@@ -72,7 +72,7 @@ class FlipperClient : public FlipperConnectionManager::Callbacks {
void refreshPlugins();
void setStateListener(
std::shared_ptr<SonarStateUpdateListener> stateListener);
std::shared_ptr<FlipperStateUpdateListener> stateListener);
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<FlipperConnectionImpl>> connections_;
std::mutex mutex_;
std::shared_ptr<SonarState> sonarState_;
std::shared_ptr<FlipperState> sonarState_;
void performAndReportError(const std::function<void()>& func);
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) {
CHECK_THROW(config.callbackWorker, std::invalid_argument);
CHECK_THROW(config.connectionWorker, std::invalid_argument);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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