Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes SavePublisherState #5620

Merged
merged 1 commit into from
May 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -965,38 +965,6 @@ void RewardsServiceImpl::OnLedgerStateSaved(
: ledger::Result::NO_LEDGER_STATE);
}

void RewardsServiceImpl::SavePublisherState(
const std::string& publisher_state,
ledger::ResultCallback callback) {
if (reset_states_) {
return;
}
base::ImportantFileWriter writer(publisher_state_path_, file_task_runner_);

writer.RegisterOnNextWriteCallbacks(
base::Closure(),
base::Bind(
&PostWriteCallback,
base::Bind(
&RewardsServiceImpl::OnPublisherStateSaved,
AsWeakPtr(),
callback),
base::SequencedTaskRunnerHandle::Get()));

writer.WriteNow(std::make_unique<std::string>(publisher_state));
}

void RewardsServiceImpl::OnPublisherStateSaved(
ledger::ResultCallback callback,
bool success) {
if (!Connected())
return;

callback(success
? ledger::Result::LEDGER_OK
: ledger::Result::LEDGER_ERROR);
}

void RewardsServiceImpl::LoadNicewareList(
ledger::GetNicewareListCallback callback) {
if (!Connected())
Expand Down
6 changes: 0 additions & 6 deletions components/brave_rewards/browser/rewards_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,6 @@ class RewardsServiceImpl : public RewardsService,
void OnLedgerStateLoaded(ledger::OnLoadCallback callback,
std::pair<std::string, base::Value> data);
void LoadNicewareList(ledger::GetNicewareListCallback callback) override;
void OnPublisherStateSaved(
ledger::ResultCallback callback,
bool success);
void OnPublisherStateLoaded(ledger::OnLoadCallback callback,
const std::string& data);
void OnFetchWalletProperties(const ledger::Result result,
Expand Down Expand Up @@ -489,9 +486,6 @@ class RewardsServiceImpl : public RewardsService,
void SaveLedgerState(
const std::string& ledger_state,
ledger::ResultCallback callback) override;
void SavePublisherState(
const std::string& publisher_state,
ledger::ResultCallback callback) override;
void SetTimer(uint64_t time_offset, uint32_t* timer_id) override;
void LoadURL(const std::string& url,
const std::vector<std::string>& headers,
Expand Down
21 changes: 0 additions & 21 deletions components/services/bat_ledger/bat_ledger_client_mojo_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,27 +168,6 @@ void BatLedgerClientMojoProxy::SaveLedgerState(
base::BindOnce(&OnSaveLedgerState, std::move(callback)));
}

void BatLedgerClientMojoProxy::OnSavePublisherState(
ledger::ResultCallback callback,
const ledger::Result result) {
callback(result);
}

void BatLedgerClientMojoProxy::SavePublisherState(
const std::string& publisher_state,
ledger::ResultCallback callback) {
if (!Connected()) {
callback(ledger::Result::LEDGER_ERROR);
return;
}

bat_ledger_client_->SavePublisherState(
publisher_state,
base::BindOnce(&BatLedgerClientMojoProxy::OnSavePublisherState,
AsWeakPtr(),
callback));
}

void BatLedgerClientMojoProxy::SetTimer(uint64_t time_offset,
uint32_t* timer_id) {
if (!Connected()) {
Expand Down
6 changes: 0 additions & 6 deletions components/services/bat_ledger/bat_ledger_client_mojo_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class BatLedgerClientMojoProxy : public ledger::LedgerClient,
void SaveLedgerState(
const std::string& ledger_state,
ledger::ResultCallback callback) override;
void SavePublisherState(
const std::string& publisher_state,
ledger::ResultCallback callback) override;
void SetTimer(uint64_t time_offset, uint32_t* timer_id) override;
void KillTimer(const uint32_t timer_id) override;

Expand Down Expand Up @@ -155,9 +152,6 @@ class BatLedgerClientMojoProxy : public ledger::LedgerClient,
const ledger::Result result, const std::string& data);
void OnLoadPublisherState(ledger::OnLoadCallback callback,
const ledger::Result result, const std::string& data);
void OnSavePublisherState(
ledger::ResultCallback callback,
const ledger::Result result);

DISALLOW_COPY_AND_ASSIGN(BatLedgerClientMojoProxy);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,29 +94,6 @@ void LedgerClientMojoProxy::SaveLedgerState(
_1));
}

// static
void LedgerClientMojoProxy::OnSavePublisherState(
CallbackHolder<SavePublisherStateCallback>* holder,
const ledger::Result result) {
DCHECK(holder);
if (holder->is_valid()) {
std::move(holder->get()).Run(result);
}
delete holder;
}

void LedgerClientMojoProxy::SavePublisherState(
const std::string& publisher_state,
SavePublisherStateCallback callback) {
auto* holder = new CallbackHolder<SavePublisherStateCallback>(
AsWeakPtr(), std::move(callback));
ledger_client_->SavePublisherState(
publisher_state,
std::bind(LedgerClientMojoProxy::OnSavePublisherState,
holder,
_1));
}

void LedgerClientMojoProxy::OnReconcileComplete(
const ledger::Result result,
const std::string& contribution_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ class LedgerClientMojoProxy : public mojom::BatLedgerClient,
void LoadPublisherState(LoadPublisherStateCallback callback) override;
void SaveLedgerState(const std::string& ledger_state,
SaveLedgerStateCallback callback) override;
void SavePublisherState(
const std::string& publisher_state,
SavePublisherStateCallback callback) override;

void FetchFavIcon(const std::string& url, const std::string& favicon_key,
FetchFavIconCallback callback) override;
Expand Down Expand Up @@ -185,10 +182,6 @@ class LedgerClientMojoProxy : public mojom::BatLedgerClient,
Callback callback_;
};

static void OnSavePublisherState(
CallbackHolder<SavePublisherStateCallback>* holder,
const ledger::Result result);

static void OnSaveLedgerState(
CallbackHolder<SaveLedgerStateCallback>* holder,
const ledger::Result result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ interface BatLedgerClient {
LoadLedgerState() => (ledger.mojom.Result result, string data);
LoadPublisherState() => (ledger.mojom.Result result, string data);
SaveLedgerState(string ledger_state) => (ledger.mojom.Result result);
SavePublisherState(string publisher_state) => (ledger.mojom.Result result);

OnWalletProperties(ledger.mojom.Result result, ledger.mojom.WalletProperties? properties);
OnReconcileComplete(ledger.mojom.Result result, string viewing_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ class ConfirmationsClientMock : public ConfirmationsClient {
MOCK_METHOD1(LoadPublisherState, void(
ledger::OnLoadCallback callback));

MOCK_METHOD2(SavePublisherState, void(
const std::string& publisher_state,
ledger::ResultCallback callback));

MOCK_METHOD1(LoadNicewareList, void(
ledger::GetNicewareListCallback callback));

Expand Down
4 changes: 0 additions & 4 deletions vendor/bat-native-ledger/include/bat/ledger/ledger_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ class LEDGER_EXPORT LedgerClient {

virtual void LoadPublisherState(OnLoadCallback callback) = 0;

virtual void SavePublisherState(
const std::string& publisher_state,
ResultCallback callback) = 0;

virtual void LoadNicewareList(ledger::GetNicewareListCallback callback) = 0;

virtual void OnPanelPublisherInfo(Result result,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ class MockLedgerClient : public LedgerClient {
MOCK_METHOD1(LoadPublisherState, void(
ledger::OnLoadCallback callback));

MOCK_METHOD2(SavePublisherState, void(
const std::string& publisher_state,
ledger::ResultCallback callback));

MOCK_METHOD1(LoadNicewareList, void(
ledger::GetNicewareListCallback callback));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,6 @@ void LedgerImpl::SaveLedgerState(
ledger_client_->SaveLedgerState(data, callback);
}

void LedgerImpl::SavePublisherState(
const std::string& data,
ledger::ResultCallback callback) {
ledger_client_->SavePublisherState(data, callback);
}

void LedgerImpl::LoadURL(
const std::string& url,
const std::vector<std::string>& headers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,6 @@ class LedgerImpl : public ledger::Ledger {
const std::string& data,
ledger::ResultCallback callback);

void SavePublisherState(
const std::string& data,
ledger::ResultCallback callback);

void LoadNicewareList(ledger::GetNicewareListCallback callback);

void SetConfirmationsWalletInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ class MockLedgerImpl : public LedgerImpl {

MOCK_METHOD1(SaveLedgerState, void(const std::string&));

MOCK_METHOD2(SavePublisherState, void(
const std::string&,
ledger::ResultCallback));

MOCK_METHOD1(LoadNicewareList, void(ledger::GetNicewareListCallback));

MOCK_METHOD1(SetConfirmationsWalletInfo,
Expand Down
6 changes: 0 additions & 6 deletions vendor/brave-ios/Ledger/BATBraveLedger.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1750,12 +1750,6 @@ - (void)loadPublisherState:(ledger::OnLoadCallback)callback
}
}

- (void)savePublisherState:(const std::string &)publisher_state callback:(ledger::ResultCallback)callback
{
const auto result = [self.commonOps saveContents:publisher_state name:"publisher_state.json"];
callback(result ? ledger::Result::LEDGER_OK : ledger::Result::LEDGER_ERROR);
}

- (void)loadState:(const std::string &)name callback:(ledger::OnLoadCallback)callback
{
const auto key = [NSString stringWithUTF8String:name.c_str()];
Expand Down
1 change: 0 additions & 1 deletion vendor/brave-ios/Ledger/Generated/NativeLedgerClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class NativeLedgerClient : public ledger::LedgerClient {
void ResetState(const std::string & name, ledger::ResultCallback callback) override;
void SaveLedgerState(const std::string & ledger_state, ledger::ResultCallback callback) override;
void PublisherListNormalized(ledger::PublisherInfoList list) override;
void SavePublisherState(const std::string & publisher_state, ledger::ResultCallback callback) override;
void SaveState(const std::string & name, const std::string & value, ledger::ResultCallback callback) override;
void SetConfirmationsIsReady(const bool is_ready) override;
void SetTimer(uint64_t time_offset, uint32_t * timer_id) override;
Expand Down
3 changes: 0 additions & 3 deletions vendor/brave-ios/Ledger/Generated/NativeLedgerClient.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@
void NativeLedgerClient::PublisherListNormalized(ledger::PublisherInfoList list) {
[bridge_ publisherListNormalized:std::move(list)];
}
void NativeLedgerClient::SavePublisherState(const std::string & publisher_state, ledger::ResultCallback callback) {
[bridge_ savePublisherState:publisher_state callback:callback];
}
void NativeLedgerClient::SaveState(const std::string & name, const std::string & value, ledger::ResultCallback callback) {
[bridge_ saveState:name value:value callback:callback];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
- (void)resetState:(const std::string &)name callback:(ledger::ResultCallback)callback;
- (void)saveLedgerState:(const std::string &)ledger_state callback:(ledger::ResultCallback)callback;
- (void)publisherListNormalized:(ledger::PublisherInfoList)list;
- (void)savePublisherState:(const std::string &)publisher_state callback:(ledger::ResultCallback)callback;
- (void)saveState:(const std::string &)name value:(const std::string &)value callback:(ledger::ResultCallback)callback;
- (void)setConfirmationsIsReady:(const bool)is_ready;
- (void)setTimer:(uint64_t)time_offset timerId:(uint32_t *)timer_id;
Expand Down