Skip to content

Commit

Permalink
Merge pull request #2067 from brave/uplift_2058
Browse files Browse the repository at this point in the history
Uplift Revert PR #1943 and #2035 for 0.63.x
  • Loading branch information
yrliou authored Mar 25, 2019
2 parents 0a0a0b5 + 5376b40 commit a5452f4
Show file tree
Hide file tree
Showing 35 changed files with 359 additions and 1,064 deletions.
45 changes: 2 additions & 43 deletions components/brave_rewards/browser/rewards_service_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -387,41 +387,6 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, HandleFlagsSingleArg) {
GetProduction();
RunUntilIdle();

// SetDebug(true)
EXPECT_CALL(*this, OnGetDebug(true));
// Debug - true and 1
EXPECT_CALL(*this, OnGetDebug(false)).Times(2);
// Debug - false and random
EXPECT_CALL(*this, OnGetDebug(true)).Times(2);

rewards_service()->SetDebug(true);
GetDebug();
RunUntilIdle();

// Debug - true
rewards_service()->SetDebug(true);
rewards_service()->HandleFlags("debug=true");
GetDebug();
RunUntilIdle();

// Debug - 1
rewards_service()->SetDebug(true);
rewards_service()->HandleFlags("debug=1");
GetDebug();
RunUntilIdle();

// Debug - false
rewards_service()->SetDebug(false);
rewards_service()->HandleFlags("debug=false");
GetDebug();
RunUntilIdle();

// Debug - random
rewards_service()->SetDebug(false);
rewards_service()->HandleFlags("debug=werwe");
GetDebug();
RunUntilIdle();

// positive number
EXPECT_CALL(*this, OnGetReconcileTime(10));
// negative number and string
Expand Down Expand Up @@ -463,42 +428,36 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, HandleFlagsSingleArg) {

IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, HandleFlagsMultipleFlags) {
EXPECT_CALL(*this, OnGetProduction(false));
EXPECT_CALL(*this, OnGetDebug(false));
EXPECT_CALL(*this, OnGetReconcileTime(10));
EXPECT_CALL(*this, OnGetShortRetries(true));

rewards_service()->SetProduction(true);
rewards_service()->SetDebug(true);
rewards_service()->SetReconcileTime(0);
rewards_service()->SetShortRetries(false);

rewards_service()->HandleFlags(
"staging=true,debug=true,short-retries=true,reconcile-interval=10");
"staging=true,short-retries=true,reconcile-interval=10");

GetReconcileTime();
GetShortRetries();
GetProduction();
GetDebug();
RunUntilIdle();
}

IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, HandleFlagsWrongInput) {
EXPECT_CALL(*this, OnGetProduction(true));
EXPECT_CALL(*this, OnGetDebug(true));
EXPECT_CALL(*this, OnGetReconcileTime(0));
EXPECT_CALL(*this, OnGetShortRetries(false));

rewards_service()->SetProduction(true);
rewards_service()->SetDebug(true);
rewards_service()->SetReconcileTime(0);
rewards_service()->SetShortRetries(false);

rewards_service()->HandleFlags(
"staging=,debug=,shortretries=true,reconcile-interval");
"staging=,shortretries=true,reconcile-interval");

GetReconcileTime();
GetShortRetries();
GetProduction();
GetDebug();
RunUntilIdle();
}
20 changes: 0 additions & 20 deletions components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,6 @@ void RewardsServiceImpl::StartLedger() {
#endif
SetProduction(isProduction);

SetDebug(false);

const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();

Expand Down Expand Up @@ -2446,20 +2444,6 @@ void RewardsServiceImpl::HandleFlags(const std::string& options) {
continue;
}

if (name == "debug") {
bool is_debug;
std::string lower = base::ToLowerASCII(value);

if (lower == "true" || lower == "1") {
is_debug = true;
} else {
is_debug = false;
}

SetDebug(is_debug);
continue;
}

if (name == "reconcile-interval") {
int reconcile_int;
bool success = base::StringToInt(value, &reconcile_int);
Expand Down Expand Up @@ -2564,10 +2548,6 @@ void RewardsServiceImpl::SetProduction(bool production) {
bat_ledger_service_->SetProduction(production);
}

void RewardsServiceImpl::SetDebug(bool debug) {
bat_ledger_service_->SetDebug(debug);
}

void RewardsServiceImpl::SetReconcileTime(int32_t time) {
bat_ledger_service_->SetReconcileTime(time);
}
Expand Down
3 changes: 0 additions & 3 deletions components/brave_rewards/browser/rewards_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class PublisherInfoDatabase;
class RewardsNotificationServiceImpl;

using GetProductionCallback = base::Callback<void(bool)>;
using GetDebugCallback = base::Callback<void(bool)>;
using GetReconcileTimeCallback = base::Callback<void(int32_t)>;
using GetShortRetriesCallback = base::Callback<void(bool)>;

Expand Down Expand Up @@ -177,8 +176,6 @@ class RewardsServiceImpl : public RewardsService,
void HandleFlags(const std::string& options);
void SetProduction(bool production);
void GetProduction(const GetProductionCallback& callback);
void SetDebug(bool debug);
void GetDebug(const GetDebugCallback& callback);
void SetReconcileTime(int32_t time);
void GetReconcileTime(const GetReconcileTimeCallback& callback);
void SetShortRetries(bool short_retries);
Expand Down
13 changes: 0 additions & 13 deletions components/services/bat_ledger/bat_ledger_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ bool testing() {
return ledger::is_testing;
}

bool debug() {
return ledger::is_debug;
}

}

namespace bat_ledger {
Expand Down Expand Up @@ -48,11 +44,6 @@ void BatLedgerServiceImpl::SetProduction(bool is_production) {
ledger::is_production = is_production;
}

void BatLedgerServiceImpl::SetDebug(bool is_debug) {
DCHECK(!initialized_ || debug());
ledger::is_debug = is_debug;
}

void BatLedgerServiceImpl::SetReconcileTime(int32_t time) {
DCHECK(!initialized_ || testing());
ledger::reconcile_time = time;
Expand All @@ -71,10 +62,6 @@ void BatLedgerServiceImpl::GetProduction(GetProductionCallback callback) {
std::move(callback).Run(ledger::is_production);
}

void BatLedgerServiceImpl::GetDebug(GetDebugCallback callback) {
std::move(callback).Run(ledger::is_debug);
}

void BatLedgerServiceImpl::GetReconcileTime(GetReconcileTimeCallback callback) {
std::move(callback).Run(ledger::reconcile_time);
}
Expand Down
59 changes: 28 additions & 31 deletions components/services/bat_ledger/bat_ledger_service_impl.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* Copyright (c) 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef COMPONENTS_SERVICES_BAT_LEDGER_BAT_LEDGER_SERVICE_IMPL_H_
#define COMPONENTS_SERVICES_BAT_LEDGER_BAT_LEDGER_SERVICE_IMPL_H_
#ifndef BRAVE_COMPONENTS_SERVICES_BAT_LEDGER_BAT_LEDGER_SERVICE_IMPL_H_
#define BRAVE_COMPONENTS_SERVICES_BAT_LEDGER_BAT_LEDGER_SERVICE_IMPL_H_

#include <memory>

Expand All @@ -14,33 +13,31 @@
namespace bat_ledger {

class BatLedgerServiceImpl : public mojom::BatLedgerService {
public:
explicit BatLedgerServiceImpl(
std::unique_ptr<service_manager::ServiceContextRef> service_ref);
~BatLedgerServiceImpl() override;

// bat_ledger::mojom::BatLedgerService
void Create(mojom::BatLedgerClientAssociatedPtrInfo client_info,
mojom::BatLedgerAssociatedRequest bat_ledger) override;

void SetProduction(bool isProduction) override;
void SetDebug(bool isDebug) override;
void SetReconcileTime(int32_t time) override;
void SetShortRetries(bool short_retries) override;
void SetTesting() override;

void GetProduction(GetProductionCallback callback) override;
void GetDebug(GetDebugCallback callback) override;
void GetReconcileTime(GetReconcileTimeCallback callback) override;
void GetShortRetries(GetShortRetriesCallback callback) override;

private:
const std::unique_ptr<service_manager::ServiceContextRef> service_ref_;
bool initialized_;

DISALLOW_COPY_AND_ASSIGN(BatLedgerServiceImpl);
public:
explicit BatLedgerServiceImpl(
std::unique_ptr<service_manager::ServiceContextRef> service_ref);
~BatLedgerServiceImpl() override;

// bat_ledger::mojom::BatLedgerService
void Create(mojom::BatLedgerClientAssociatedPtrInfo client_info,
mojom::BatLedgerAssociatedRequest bat_ledger) override;

void SetProduction(bool isProduction) override;
void SetReconcileTime(int32_t time) override;
void SetShortRetries(bool short_retries) override;
void SetTesting() override;

void GetProduction(GetProductionCallback callback) override;
void GetReconcileTime(GetReconcileTimeCallback callback) override;
void GetShortRetries(GetShortRetriesCallback callback) override;

private:
const std::unique_ptr<service_manager::ServiceContextRef> service_ref_;
bool initialized_;

DISALLOW_COPY_AND_ASSIGN(BatLedgerServiceImpl);
};

} // namespace bat_ledger
} // namespace bat_ledger

#endif // COMPONENTS_SERVICES_BAT_LEDGER_BAT_LEDGER_SERVICE_IMPL_H_
#endif // BRAVE_COMPONENTS_SERVICES_BAT_LEDGER_BAT_LEDGER_SERVICE_IMPL_H_
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ interface BatLedgerService {
Create(associated BatLedgerClient bat_ledger_client,
associated BatLedger& bat_ledger);
SetProduction(bool isProduction);
SetDebug(bool isDebug);
SetReconcileTime(int32 time);
SetShortRetries(bool short_retries);
SetTesting();

GetProduction() => (bool production);
GetDebug() => (bool debug);
GetReconcileTime() => (int32 time);
GetShortRetries() => (bool short_retries);
};
Expand Down
1 change: 0 additions & 1 deletion vendor/bat-native-ads/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ source_set("ads") {
"src/bat/ads/bundle_state.cc",
"src/bat/ads/client_info.cc",
"src/bat/ads/issuer_info.cc",
"src/bat/ads/confirmation_type.cc",
"src/bat/ads/issuers_info.cc",
"src/bat/ads/notification_info.cc",
"src/bat/ads/internal/ads_impl.cc",
Expand Down
37 changes: 11 additions & 26 deletions vendor/bat-native-ads/include/bat/ads/confirmation_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,19 @@
#ifndef BAT_ADS_CONFIRMATION_TYPE_H_
#define BAT_ADS_CONFIRMATION_TYPE_H_

#include <string>

namespace ads {

class ConfirmationType {
public:
enum Value : int {
UNKNOWN,
CLICK,
DISMISS,
VIEW,
LANDED
};

ConfirmationType() = default;
constexpr ConfirmationType(const Value value) : value_(value) {}
explicit ConfirmationType(const std::string& value);

bool IsSupported() const;

int value() const;
operator std::string() const;

bool operator==(ConfirmationType type) const;
bool operator!=(ConfirmationType type) const;

private:
Value value_;
static char kConfirmationTypeClick[] = "click";
static char kConfirmationTypeDismiss[] = "dismiss";
static char kConfirmationTypeView[] = "view";
static char kConfirmationTypeLanded[] = "landed";

enum class ConfirmationType {
UNKNOWN,
CLICK,
DISMISS,
VIEW,
LANDED
};

} // namespace ads
Expand Down
69 changes: 0 additions & 69 deletions vendor/bat-native-ads/src/bat/ads/confirmation_type.cc

This file was deleted.

Loading

0 comments on commit a5452f4

Please sign in to comment.