-
Notifications
You must be signed in to change notification settings - Fork 879
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
Confirmations implementation #1469
Conversation
@@ -1218,7 +1218,7 @@ void RewardsServiceImpl::OnURLFetchComplete( | |||
return; | |||
} | |||
|
|||
callback(response_code == 200, body, headers); | |||
callback(response_code, body, headers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nejc Would be good if you could verify that this commit was done correctly, as far as Rewards is concerned.
@@ -578,18 +580,18 @@ void AdsServiceImpl::ShowNotification(std::unique_ptr<ads::NotificationInfo> inf | |||
} | |||
|
|||
void AdsServiceImpl::SetCatalogIssuers(std::unique_ptr<ads::IssuersInfo> info) { | |||
// TODO(Terry Mancey): https://github.com/brave/brave-browser/issues/2906 | |||
(void)info; | |||
rewards_service_->SetCatalogIssuers(std::move(info)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this return early if (!connected())
? I see other methods in here doing that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍, ideally we should be checking bounds for the rewards service however the lifetime of the rewards service outlasts Ads
ledger::URL_METHOD method, | ||
ledger::URLRequestCallback callback) { | ||
if (!Connected()) { | ||
callback(418, "", std::map<std::string, std::string>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This HTTP response seems random (I copied it from similar functionality in bat_ledger). Should it just be a generic 400 (and preferably some kind of constant - Chromium probably has definitions for these).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was chosen as an unlikely response that we would get in the real world so that we knew the service had failed. @bridiver your thoughts please? If we do want to use a constant they are available in src/net/http/http_status_code_list.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be here at all. The mojo proxy shouldn't have any logic in it
ec86ca4
to
2cc4133
Compare
6141c86
to
e7301ed
Compare
1410050
to
193f900
Compare
return; | ||
} | ||
|
||
auto* ads_service = brave_ads::AdsServiceFactory::GetForProfile(profile_); // NOT OWNED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are we calling this from rewards_service if it calls ads_service?
} | ||
|
||
void RewardsServiceImpl::SetConfirmationsIsReady(const bool is_ready) { | ||
if (!Connected()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is only necessary when we're using the mojo interfaces
fetcher->Start(); | ||
} | ||
|
||
void RewardsServiceImpl::SaveConfirmationsState(const std::string& name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need individual methods for these. We just need a generic Save
and Load
method like AdsService which can be used by all state files
bat_ledger_->AdSustained(info->ToJson()); | ||
} | ||
|
||
void RewardsServiceImpl::URLRequest(const std::string& url, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we adding this? We already have LoadURL
@@ -112,6 +112,36 @@ class LogStreamImpl : public ledger::LogStream { | |||
DISALLOW_COPY_AND_ASSIGN(LogStreamImpl); | |||
}; | |||
|
|||
class ConfirmationsLogStreamImpl : public confirmations::LogStream { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need duplicates of all this stuff for Confirmations
@@ -257,6 +287,27 @@ time_t GetCurrentTimestamp() { | |||
return base::Time::NowFromSystemTime().ToTimeT(); | |||
} | |||
|
|||
std::string LoadOnFileTaskRunner(const base::FilePath& path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need duplicates of this stuff either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to go through this together because there are a lot of issues here that need to be addressed
011c7d7
to
ca3621b
Compare
9b5662f
to
56ca660
Compare
Upgrading remaining grant endpoints to v4
56ca660
to
ffd166c
Compare
@@ -94,6 +94,8 @@ source_set("browser") { | |||
} | |||
|
|||
deps += [ | |||
"//brave/vendor/bat-native-ads", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs a brave_ads_enabled guard
@@ -20,6 +20,8 @@ static_library("lib") { | |||
|
|||
deps = [ | |||
"//base", | |||
"//brave/vendor/bat-native-ads", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here with brave_ads_enabled
#include "bat/ledger/ledger_client.h" | ||
#include "brave/components/services/bat_ledger/public/interfaces/bat_ledger.mojom.h" | ||
#include "brave/components/brave_rewards/browser/rewards_service.h" | ||
#include "brave/components/brave_ads/browser/ads_service.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no reason for these to be here. Only add includes to the header file if they are needed for the declaration. Everything else should go in the cc file
@@ -10,14 +10,19 @@ | |||
#include <memory> | |||
#include <string> | |||
|
|||
#include "bat/ads/issuers_info.h" | |||
#include "bat/ads/notification_info.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be a forward declaration
#include "bat/ledger/ledger.h" | ||
#include "bat/ledger/wallet_info.h" | ||
#include "base/files/file_path.h" | ||
#include "base/observer_list.h" | ||
#include "base/memory/weak_ptr.h" | ||
#include "bat/confirmations/confirmations_client.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't appear to be needed at all
@@ -10,14 +10,19 @@ | |||
#include <memory> | |||
#include <string> | |||
|
|||
#include "bat/ads/issuers_info.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be a forward declaration
CurrentReconciles current_reconciles_; | ||
bool auto_contribute_ = false; | ||
bool rewards_enabled_ = false; | ||
}; | ||
|
||
struct GRANTS_PROPERTIES_ST { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is a vector of grant responses called GRANTS_PROPERTIES_ST
? Also we should stop using this all caps naming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was following the naming conventions of the other response structs, I can update
ledger::OnLoadCallback callback) = 0; | ||
virtual void ResetConfirmationsState(const std::string& name, | ||
ledger::OnResetCallback callback) = 0; | ||
virtual uint32_t SetConfirmationsTimer(const uint64_t time_offset) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't have duplicates of this either
ledger::OnResetCallback callback) = 0; | ||
virtual uint32_t SetConfirmationsTimer(const uint64_t time_offset) = 0; | ||
virtual void KillConfirmationsTimer(uint32_t timer_id) = 0; | ||
virtual void SetConfirmationsIsReady(const bool is_ready) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this both a Ledger and LedgerClient method? I'm very confused about what it's supposed to do
@@ -584,6 +592,20 @@ void AdsServiceImpl::ShowNotification( | |||
timer_id, notification_id)); | |||
} | |||
|
|||
void AdsServiceImpl::SetCatalogIssuers(std::unique_ptr<ads::IssuersInfo> info) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we calling this on ads service if it calls rewards service?
components/brave_rewards/browser/rewards_notification_service_impl.cc
Outdated
Show resolved
Hide resolved
const ledger::URL_METHOD method, | ||
ledger::URLRequestCallback callback) = 0; | ||
|
||
virtual void SaveConfirmationsState(const std::string& name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this stuff should not be added to LedgerClient, LedgerImpl should just proxy to the LedgerClient methods for SetTimer, LoadURL, etc..
setGrants -> setGrant
Adding test to reflect change
375e361
to
a2ef113
Compare
Closing PR as superseded by #1645 |
Add options for installer signing key on Mac
Add options for installer signing key on Mac
Add options for installer signing key on Mac
fixes brave/brave-browser#3117
Submitter Checklist:
npm test brave_unit_tests && npm test brave_browser_tests
) ongit rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist: