From c44370f24751cfc6a68d89c490874fa14b201597 Mon Sep 17 00:00:00 2001 From: SergeyZhukovsky Date: Mon, 13 Aug 2018 18:57:15 -0400 Subject: [PATCH 1/5] Save Publishers calls --- include/bat/ledger/ledger.h | 11 +++--- include/bat/ledger/ledger_client.h | 2 ++ src/bat/ledger/ledger.cc | 7 ++-- src/bat_client.cc | 11 +++--- src/bat_helper.cc | 12 +++++++ src/bat_publishers.cc | 11 +++--- src/bat_publishers.h | 3 +- src/ledger_impl.cc | 57 ++++++++++++++++++++++++------ src/ledger_impl.h | 7 ++++ 9 files changed, 93 insertions(+), 28 deletions(-) diff --git a/include/bat/ledger/ledger.h b/include/bat/ledger/ledger.h index fa9e79563ce6..f255aba6ac4a 100644 --- a/include/bat/ledger/ledger.h +++ b/include/bat/ledger/ledger.h @@ -15,16 +15,17 @@ namespace ledger { LEDGER_EXPORT struct VisitData { + VisitData(); VisitData(const std::string& _tld, const std::string& _domain, const std::string& _path, uint32_t tab_id); VisitData(const VisitData& data); - const std::string tld; - const std::string domain; - const std::string path; - const uint32_t tab_id; - uint64_t duration; + std::string tld; + std::string domain; + std::string path; + uint32_t tab_id; + //uint64_t duration; }; class LEDGER_EXPORT Ledger { diff --git a/include/bat/ledger/ledger_client.h b/include/bat/ledger/ledger_client.h index f224b8d55963..3664893df66d 100644 --- a/include/bat/ledger/ledger_client.h +++ b/include/bat/ledger/ledger_client.h @@ -80,6 +80,8 @@ class LEDGER_EXPORT LedgerClient { // If any callbacks are made from inside RunIOTask you must use // RunTask to return back to the calling thread virtual void RunTask(std::unique_ptr task) = 0; + // Get current time in milliseconds + virtual uint64_t GetCurrentTime() = 0; }; } // namespace ledger diff --git a/src/bat/ledger/ledger.cc b/src/bat/ledger/ledger.cc index c09698db0544..8402e6927b95 100644 --- a/src/bat/ledger/ledger.cc +++ b/src/bat/ledger/ledger.cc @@ -11,6 +11,9 @@ namespace ledger { +VisitData::VisitData(): + tab_id(0) {} + VisitData::VisitData(const std::string& _tld, const std::string& _domain, const std::string& _path, @@ -24,11 +27,11 @@ VisitData::VisitData(const VisitData& data) : tld(data.tld), domain(data.domain), path(data.path), - tab_id(data.tab_id), - duration(data.duration) {} + tab_id(data.tab_id) {} const PublisherInfo invalid(""); + PublisherInfo::PublisherInfo(const id_type& publisher_id) : id(publisher_id), duration(0u), diff --git a/src/bat_client.cc b/src/bat_client.cc index 5d3c3173fa93..b5ce2eed5477 100644 --- a/src/bat_client.cc +++ b/src/bat_client.cc @@ -266,9 +266,10 @@ void BatClient::reconcileCallback(bool result, const std::string& response) { void BatClient::currentReconcile() { std::ostringstream amount; amount << state_->fee_amount_; - std::string path = (std::string)WALLET_PROPERTIES + state_->walletInfo_.paymentId_ + "?refresh=true&amount=" + amount.str() + "&altcurrency=" + state_->fee_currency_; + std::string path = (std::string)WALLET_PROPERTIES + state_->walletInfo_.paymentId_ + "?amount=" + amount.str() + "&altcurrency=" + state_->fee_currency_; - auto request_id = ledger_->LoadURL(buildURL(path, ""), + LOG(ERROR) << "!!!currentReconcile path == " << path; + auto request_id = ledger_->LoadURL(buildURL(path, PREFIX_V2), std::vector(), "", "", ledger::URL_METHOD::GET, &handler_); handler_.AddRequestHandler(std::move(request_id), @@ -279,7 +280,7 @@ void BatClient::currentReconcile() { } void BatClient::currentReconcileCallback(bool result, const std::string& response) { - //LOG(ERROR) << "!!!currentReconcileCallback response == " << response; + LOG(ERROR) << "!!!currentReconcileCallback response == " << response; if (!result) { // TODO errors handling return; @@ -343,7 +344,7 @@ void BatClient::currentReconcileCallback(bool result, const std::string& respons } void BatClient::reconcilePayloadCallback(bool result, const std::string& response) { - //LOG(ERROR) << "!!!response reconcilePayloadCallback == " << response; + LOG(ERROR) << "!!!response reconcilePayloadCallback == " << response; if (!result) { // TODO errors handling return; @@ -896,6 +897,7 @@ void BatClient::recoverWallet(const std::string& passPhrase) { braveledger_bat_helper::getPublicKeyFromSeed(secretKey, publicKey, newSecretKey); std::string publicKeyHex = braveledger_bat_helper::uint8ToHex(publicKey); + //LOG(ERROR) << "!!!recover URL == " << buildURL((std::string)RECOVER_WALLET_PUBLIC_KEY + publicKeyHex, ""); auto request_id = ledger_->LoadURL(buildURL((std::string)RECOVER_WALLET_PUBLIC_KEY + publicKeyHex, ""), std::vector(), "", "", ledger::URL_METHOD::GET, &handler_); @@ -914,7 +916,6 @@ void BatClient::recoverWalletPublicKeyCallback(bool result, const std::string& r ledger_->OnRecoverWallet(ledger::Result::ERROR, 0); return; } - std::string recoveryId; braveledger_bat_helper::getJSONValue("paymentId", response, recoveryId); diff --git a/src/bat_helper.cc b/src/bat_helper.cc index 08f87ff263b7..700db6109fa7 100644 --- a/src/bat_helper.cc +++ b/src/bat_helper.cc @@ -22,6 +22,8 @@ #include "static_values.h" #include "tweetnacl.h" +//#include "crypto/hkdf.h" + namespace braveledger_bat_helper { REQUEST_CREDENTIALS_ST::REQUEST_CREDENTIALS_ST() {} @@ -1278,6 +1280,16 @@ namespace braveledger_bat_helper { DCHECK(hkdfRes); DCHECK(!seed.empty()); + + // We set the key_length to the length of the expected output and then take + // the result from the first key, which is the client write key. + //const std::string key((char*)&seed[0], seed.size()); + //const std::string salt((char*)&braveledger_ledger::g_hkdfSalt[0], SALT_LENGTH); + //crypto::HKDF hkdf(key, salt, "", SEED_LENGTH, 0, 0); + + //LOG(ERROR) << "hkdf.client_write_key() == " << hkdf.client_write_key().data(); + //memcpy(&out.front(), hkdf.client_write_key().data(), hkdf.client_write_key().size()); + return out; } diff --git a/src/bat_publishers.cc b/src/bat_publishers.cc index 7e83d8946c89..d31d5ddc6326 100644 --- a/src/bat_publishers.cc +++ b/src/bat_publishers.cc @@ -71,17 +71,17 @@ bool ignoreMinTime(const ledger::PublisherInfo::id_type publisher_id) { return !getProviderName(publisher_id).empty(); } -void BatPublishers::saveVisit(const ledger::VisitData& visit_data) { +void BatPublishers::saveVisit(const ledger::VisitData& visit_data, const uint64_t& duration) { const ledger::PublisherInfo::id_type publisher_id = getPublisherID(visit_data); if (!ignoreMinTime(publisher_id) && - visit_data.duration < state_->min_pubslisher_duration_) + duration < state_->min_pubslisher_duration_) return; ledger_->GetPublisherInfo(publisher_id, std::bind(&BatPublishers::saveVisitInternal, this, - publisher_id, visit_data, _1, _2)); + publisher_id, visit_data, duration, _1, _2)); } void onVisitSavedDummy(ledger::Result result, @@ -92,6 +92,7 @@ void onVisitSavedDummy(ledger::Result result, void BatPublishers::saveVisitInternal( ledger::PublisherInfo::id_type publisher_id, ledger::VisitData visit_data, + uint64_t duration, ledger::Result result, std::unique_ptr publisher_info) { if (result != ledger::Result::OK) { @@ -102,9 +103,9 @@ void BatPublishers::saveVisitInternal( if (!publisher_info.get()) publisher_info.reset(new ledger::PublisherInfo(publisher_id)); - publisher_info->duration += visit_data.duration; + publisher_info->duration += duration; publisher_info->visits += 1; - publisher_info->score += concaveScore(visit_data.duration); + publisher_info->score += concaveScore(duration); ledger_->SetPublisherInfo(std::move(publisher_info), std::bind(&onVisitSavedDummy, _1, _2)); diff --git a/src/bat_publishers.h b/src/bat_publishers.h index a82e0545d8d4..5faf5b365975 100644 --- a/src/bat_publishers.h +++ b/src/bat_publishers.h @@ -34,7 +34,7 @@ class BatPublishers : public ledger::LedgerCallbackHandler { void loadState(const std::string& data); - void saveVisit(const ledger::VisitData& visit_data); + void saveVisit(const ledger::VisitData& visit_data, const uint64_t& duration); void setPublisherMinVisitTime(const uint64_t& duration); // In milliseconds @@ -61,6 +61,7 @@ class BatPublishers : public ledger::LedgerCallbackHandler { void saveVisitInternal( ledger::PublisherInfo::id_type publisher_id, ledger::VisitData visit_data, + uint64_t duration, ledger::Result result, std::unique_ptr publisher_info); diff --git a/src/ledger_impl.cc b/src/ledger_impl.cc index c144549805fc..c7d95fb5f77b 100644 --- a/src/ledger_impl.cc +++ b/src/ledger_impl.cc @@ -24,7 +24,9 @@ LedgerImpl::LedgerImpl(ledger::LedgerClient* client) : bat_client_(new BatClient(this)), bat_publishers_(new BatPublishers(this)), bat_get_media_(new BatGetMedia(this)), - initialized_(false) { + last_tab_active_time_(0), + initialized_(false), + last_shown_tab_id_(0) { } LedgerImpl::~LedgerImpl() { @@ -43,39 +45,74 @@ void LedgerImpl::CreateWallet() { } void LedgerImpl::OnLoad(const ledger::VisitData& visit_data) { - + if (visit_data.domain.empty()) { + // Skip the same domain name + return; + } + visit_data_iter iter = current_pages_.find(visit_data.tab_id); + if (iter != current_pages_.end() && iter->second.domain == visit_data.domain) { + return; + } + if (last_shown_tab_id_ == visit_data.tab_id) { + last_tab_active_time_ = ledger_client_->GetCurrentTime(); + } + current_pages_[visit_data.tab_id] = visit_data; + //LOG(ERROR) << "!!!LedgerImpl::OnLoad tab_id == " << visit_data.tab_id << ", domain == " << visit_data.domain + // << ", tld == " << visit_data.tld << ", path == " << visit_data.path; } void LedgerImpl::OnUnload(uint32_t tab_id) { - + //LOG(ERROR) << "!!!LedgerImpl::OnUnload tab_id == " << tab_id; + visit_data_iter iter = current_pages_.find(tab_id); + if (iter != current_pages_.end()) { + current_pages_.erase(iter); + } } void LedgerImpl::OnShow(uint32_t tab_id) { - + //LOG(ERROR) << "!!!LedgerImpl::OnShow tab_id == " << tab_id; + last_tab_active_time_ = ledger_client_->GetCurrentTime(); + last_shown_tab_id_ = tab_id; } void LedgerImpl::OnHide(uint32_t tab_id) { - + if (tab_id != last_shown_tab_id_) { + return; + } + //LOG(ERROR) << "!!!LedgerImpl::OnHide tab_id == " << tab_id << ", time == " << (ledger_client_->GetCurrentTime() - last_tab_active_time_); + visit_data_iter iter = current_pages_.find(tab_id); + if (iter == current_pages_.end()) { + return; + } + DCHECK(last_tab_active_time_); + bat_publishers_->saveVisit(iter->second, ledger_client_->GetCurrentTime() - last_tab_active_time_); + last_tab_active_time_ = 0; } void LedgerImpl::OnForeground(uint32_t tab_id) { - + // TODO media resources could have been played in the background + if (last_shown_tab_id_ != tab_id) { + return; + } + OnShow(tab_id); } void LedgerImpl::OnBackground(uint32_t tab_id) { - + // TODO media resources could stay and be active in the background + OnHide(tab_id); } void LedgerImpl::OnMediaStart(uint32_t tab_id) { - + // TODO } void LedgerImpl::OnMediaStop(uint32_t tab_id) { - + // TODO } void LedgerImpl::OnXHRLoad(uint32_t tab_id, const std::string& url) { - + // TODO + //LOG(ERROR) << "!!!LedgerImpl::OnXHRLoad " << url; } void LedgerImpl::LoadLedgerState(ledger::LedgerCallbackHandler* handler) { diff --git a/src/ledger_impl.h b/src/ledger_impl.h index d0ae6c4da400..96df22d76ea9 100644 --- a/src/ledger_impl.h +++ b/src/ledger_impl.h @@ -34,6 +34,8 @@ namespace bat_ledger { class LedgerImpl : public ledger::Ledger, public ledger::LedgerCallbackHandler { public: + typedef std::map::const_iterator visit_data_iter; + LedgerImpl(ledger::LedgerClient* client); ~LedgerImpl() override; @@ -144,6 +146,11 @@ class LedgerImpl : public ledger::Ledger, bool initialized_; URLRequestHandler handler_; + + //ledger::VisitData current_visit_data_; + std::map current_pages_; + uint64_t last_tab_active_time_; + uint32_t last_shown_tab_id_; }; } // namespace bat_ledger From 252702efe77192efb720921287fdc25ef3b19651 Mon Sep 17 00:00:00 2001 From: SergeyZhukovsky Date: Mon, 13 Aug 2018 23:05:28 -0400 Subject: [PATCH 2/5] chromium build error fix --- src/ledger_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ledger_impl.cc b/src/ledger_impl.cc index c7d95fb5f77b..b0f9dbc9e9b6 100644 --- a/src/ledger_impl.cc +++ b/src/ledger_impl.cc @@ -24,8 +24,8 @@ LedgerImpl::LedgerImpl(ledger::LedgerClient* client) : bat_client_(new BatClient(this)), bat_publishers_(new BatPublishers(this)), bat_get_media_(new BatGetMedia(this)), - last_tab_active_time_(0), initialized_(false), + last_tab_active_time_(0), last_shown_tab_id_(0) { } From 617664e8a6b6f8236612d620861da73ddaa35844 Mon Sep 17 00:00:00 2001 From: SergeyZhukovsky Date: Tue, 14 Aug 2018 00:04:33 -0400 Subject: [PATCH 3/5] pass time to functions, onunload save event --- include/bat/ledger/ledger.h | 17 ++++++++-------- include/bat/ledger/ledger_client.h | 2 -- src/ledger_impl.cc | 31 +++++++++++++++--------------- src/ledger_impl.h | 16 +++++++-------- 4 files changed, 32 insertions(+), 34 deletions(-) diff --git a/include/bat/ledger/ledger.h b/include/bat/ledger/ledger.h index f255aba6ac4a..31fd91983954 100644 --- a/include/bat/ledger/ledger.h +++ b/include/bat/ledger/ledger.h @@ -25,7 +25,6 @@ LEDGER_EXPORT struct VisitData { std::string domain; std::string path; uint32_t tab_id; - //uint64_t duration; }; class LEDGER_EXPORT Ledger { @@ -43,14 +42,14 @@ class LEDGER_EXPORT Ledger { virtual void CreateWallet() = 0; virtual void Reconcile() = 0; - virtual void OnLoad(const VisitData& visit_data) = 0; - virtual void OnUnload(uint32_t tab_id) = 0; - virtual void OnShow(uint32_t tab_id) = 0; - virtual void OnHide(uint32_t tab_id) = 0; - virtual void OnForeground(uint32_t tab_id) = 0; - virtual void OnBackground(uint32_t tab_id) = 0; - virtual void OnMediaStart(uint32_t tab_id) = 0; - virtual void OnMediaStop(uint32_t tab_id) = 0; + virtual void OnLoad(const VisitData& visit_data, const uint64_t& current_time) = 0; + virtual void OnUnload(uint32_t tab_id, const uint64_t& current_time) = 0; + virtual void OnShow(uint32_t tab_id, const uint64_t& current_time) = 0; + virtual void OnHide(uint32_t tab_id, const uint64_t& current_time) = 0; + virtual void OnForeground(uint32_t tab_id, const uint64_t& current_time) = 0; + virtual void OnBackground(uint32_t tab_id, const uint64_t& current_time) = 0; + virtual void OnMediaStart(uint32_t tab_id, const uint64_t& current_time) = 0; + virtual void OnMediaStop(uint32_t tab_id, const uint64_t& current_time) = 0; virtual void OnXHRLoad(uint32_t tab_id, const std::string& url) = 0; virtual void SetPublisherInfo(std::unique_ptr publisher_info, diff --git a/include/bat/ledger/ledger_client.h b/include/bat/ledger/ledger_client.h index 3664893df66d..f224b8d55963 100644 --- a/include/bat/ledger/ledger_client.h +++ b/include/bat/ledger/ledger_client.h @@ -80,8 +80,6 @@ class LEDGER_EXPORT LedgerClient { // If any callbacks are made from inside RunIOTask you must use // RunTask to return back to the calling thread virtual void RunTask(std::unique_ptr task) = 0; - // Get current time in milliseconds - virtual uint64_t GetCurrentTime() = 0; }; } // namespace ledger diff --git a/src/ledger_impl.cc b/src/ledger_impl.cc index b0f9dbc9e9b6..b48eabdd39d9 100644 --- a/src/ledger_impl.cc +++ b/src/ledger_impl.cc @@ -44,7 +44,7 @@ void LedgerImpl::CreateWallet() { bat_client_->registerPersona(); } -void LedgerImpl::OnLoad(const ledger::VisitData& visit_data) { +void LedgerImpl::OnLoad(const ledger::VisitData& visit_data, const uint64_t& current_time) { if (visit_data.domain.empty()) { // Skip the same domain name return; @@ -54,59 +54,60 @@ void LedgerImpl::OnLoad(const ledger::VisitData& visit_data) { return; } if (last_shown_tab_id_ == visit_data.tab_id) { - last_tab_active_time_ = ledger_client_->GetCurrentTime(); + last_tab_active_time_ = current_time; } current_pages_[visit_data.tab_id] = visit_data; //LOG(ERROR) << "!!!LedgerImpl::OnLoad tab_id == " << visit_data.tab_id << ", domain == " << visit_data.domain // << ", tld == " << visit_data.tld << ", path == " << visit_data.path; } -void LedgerImpl::OnUnload(uint32_t tab_id) { +void LedgerImpl::OnUnload(uint32_t tab_id, const uint64_t& current_time) { //LOG(ERROR) << "!!!LedgerImpl::OnUnload tab_id == " << tab_id; + OnHide(tab_id, current_time); visit_data_iter iter = current_pages_.find(tab_id); if (iter != current_pages_.end()) { current_pages_.erase(iter); } } -void LedgerImpl::OnShow(uint32_t tab_id) { +void LedgerImpl::OnShow(uint32_t tab_id, const uint64_t& current_time) { //LOG(ERROR) << "!!!LedgerImpl::OnShow tab_id == " << tab_id; - last_tab_active_time_ = ledger_client_->GetCurrentTime(); + last_tab_active_time_ = current_time; last_shown_tab_id_ = tab_id; } -void LedgerImpl::OnHide(uint32_t tab_id) { +void LedgerImpl::OnHide(uint32_t tab_id, const uint64_t& current_time) { if (tab_id != last_shown_tab_id_) { return; } - //LOG(ERROR) << "!!!LedgerImpl::OnHide tab_id == " << tab_id << ", time == " << (ledger_client_->GetCurrentTime() - last_tab_active_time_); visit_data_iter iter = current_pages_.find(tab_id); - if (iter == current_pages_.end()) { + if (iter == current_pages_.end() || 0 == last_tab_active_time_) { return; } + //LOG(ERROR) << "!!!LedgerImpl::OnHide tab_id == " << tab_id << ", time == " << (current_time - last_tab_active_time_); DCHECK(last_tab_active_time_); - bat_publishers_->saveVisit(iter->second, ledger_client_->GetCurrentTime() - last_tab_active_time_); + bat_publishers_->saveVisit(iter->second, current_time - last_tab_active_time_); last_tab_active_time_ = 0; } -void LedgerImpl::OnForeground(uint32_t tab_id) { +void LedgerImpl::OnForeground(uint32_t tab_id, const uint64_t& current_time) { // TODO media resources could have been played in the background if (last_shown_tab_id_ != tab_id) { return; } - OnShow(tab_id); + OnShow(tab_id, current_time); } -void LedgerImpl::OnBackground(uint32_t tab_id) { +void LedgerImpl::OnBackground(uint32_t tab_id, const uint64_t& current_time) { // TODO media resources could stay and be active in the background - OnHide(tab_id); + OnHide(tab_id, current_time); } -void LedgerImpl::OnMediaStart(uint32_t tab_id) { +void LedgerImpl::OnMediaStart(uint32_t tab_id, const uint64_t& current_time) { // TODO } -void LedgerImpl::OnMediaStop(uint32_t tab_id) { +void LedgerImpl::OnMediaStop(uint32_t tab_id, const uint64_t& current_time) { // TODO } diff --git a/src/ledger_impl.h b/src/ledger_impl.h index 96df22d76ea9..ea666caf4447 100644 --- a/src/ledger_impl.h +++ b/src/ledger_impl.h @@ -106,14 +106,14 @@ class LedgerImpl : public ledger::Ledger, void RunTask(LedgerTaskRunnerImpl::Task task); private: - void OnLoad(const ledger::VisitData& visit_data) override; - void OnUnload(uint32_t tab_id) override; - void OnShow(uint32_t tab_id) override; - void OnHide(uint32_t tab_id) override; - void OnForeground(uint32_t tab_id) override; - void OnBackground(uint32_t tab_id) override; - void OnMediaStart(uint32_t tab_id) override; - void OnMediaStop(uint32_t tab_id) override; + void OnLoad(const ledger::VisitData& visit_data, const uint64_t& current_time) override; + void OnUnload(uint32_t tab_id, const uint64_t& current_time) override; + void OnShow(uint32_t tab_id, const uint64_t& current_time) override; + void OnHide(uint32_t tab_id, const uint64_t& current_time) override; + void OnForeground(uint32_t tab_id, const uint64_t& current_time) override; + void OnBackground(uint32_t tab_id, const uint64_t& current_time) override; + void OnMediaStart(uint32_t tab_id, const uint64_t& current_time) override; + void OnMediaStop(uint32_t tab_id, const uint64_t& current_time) override; void OnXHRLoad(uint32_t tab_id, const std::string& url) override; void OnSetPublisherInfo(ledger::PublisherInfoCallback callback, From d95be8fd5cfe7307d4dc15ea2d28f80e2a3e66a3 Mon Sep 17 00:00:00 2001 From: SergeyZhukovsky Date: Tue, 14 Aug 2018 00:13:33 -0400 Subject: [PATCH 4/5] DCHECK on weird condition --- src/ledger_impl.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ledger_impl.cc b/src/ledger_impl.cc index b48eabdd39d9..17df4b378a12 100644 --- a/src/ledger_impl.cc +++ b/src/ledger_impl.cc @@ -51,6 +51,7 @@ void LedgerImpl::OnLoad(const ledger::VisitData& visit_data, const uint64_t& cur } visit_data_iter iter = current_pages_.find(visit_data.tab_id); if (iter != current_pages_.end() && iter->second.domain == visit_data.domain) { + DCHECK(iter == current_pages_.end()); return; } if (last_shown_tab_id_ == visit_data.tab_id) { From d34322ca2e177a822efba139f43eedae6bbbbaa4 Mon Sep 17 00:00:00 2001 From: SergeyZhukovsky Date: Tue, 14 Aug 2018 11:52:17 -0400 Subject: [PATCH 5/5] default value correction --- src/bat/ledger/ledger.cc | 2 +- src/ledger_impl.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bat/ledger/ledger.cc b/src/bat/ledger/ledger.cc index 8402e6927b95..62d30e6fb6fa 100644 --- a/src/bat/ledger/ledger.cc +++ b/src/bat/ledger/ledger.cc @@ -12,7 +12,7 @@ namespace ledger { VisitData::VisitData(): - tab_id(0) {} + tab_id(-1) {} VisitData::VisitData(const std::string& _tld, const std::string& _domain, diff --git a/src/ledger_impl.cc b/src/ledger_impl.cc index 17df4b378a12..101fce954880 100644 --- a/src/ledger_impl.cc +++ b/src/ledger_impl.cc @@ -26,7 +26,7 @@ LedgerImpl::LedgerImpl(ledger::LedgerClient* client) : bat_get_media_(new BatGetMedia(this)), initialized_(false), last_tab_active_time_(0), - last_shown_tab_id_(0) { + last_shown_tab_id_(-1) { } LedgerImpl::~LedgerImpl() {