Skip to content

Commit

Permalink
use TimeToValue and ValueToTime conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
antonok-edm committed Aug 20, 2021
1 parent b22e669 commit 1ab371c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
10 changes: 6 additions & 4 deletions browser/ui/webui/brave_adblock_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <utility>

#include "base/scoped_observation.h"
#include "base/util/values/values_util.h"
#include "brave/browser/brave_browser_process.h"
#include "brave/browser/ui/webui/brave_webui_source.h"
#include "brave/common/webui_url_constants.h"
Expand Down Expand Up @@ -283,10 +284,11 @@ void AdblockDOMHandler::RefreshSubscriptionsList() {
auto dict = std::make_unique<base::DictionaryValue>();
dict->SetStringKey("list_url", subscription.list_url.spec());
dict->SetBoolKey("enabled", subscription.enabled);
dict->SetDoubleKey("last_update_attempt",
subscription.last_update_attempt.ToJsTime());
dict->SetDoubleKey("last_successful_update_attempt",
subscription.last_successful_update_attempt.ToJsTime());
dict->SetKey("last_update_attempt",
util::TimeToValue(subscription.last_update_attempt));
dict->SetKey(
"last_successful_update_attempt",
util::TimeToValue(subscription.last_successful_update_attempt));
list_value->Append(std::move(dict));
}
CallJavascriptFunction("brave_adblock.onGetListSubscriptions", *list_value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ void AdBlockSubscriptionServiceManager::CreateSubscription(
FilterListSubscriptionInfo info;
info.list_url = list_url;
info.list_dir = GetSubscriptionPath(list_url);
info.last_update_attempt = base::Time::Min();
info.last_successful_update_attempt = base::Time::Min();
info.last_update_attempt = base::Time();
info.last_successful_update_attempt = base::Time();
info.enabled = true;

auto subscription_service = std::make_unique<AdBlockSubscriptionService>(
Expand Down Expand Up @@ -238,20 +238,14 @@ void AdBlockSubscriptionServiceManager::UpdateFilterListPrefs(
return;
}

// TODO(bridiver) - update for Time
// base::Value TimeToValue(base::Time time);
// base::Optional<base::Time> util::ValueToTime(const base::Value* value);
// base::Optional<base::Time> util::ValueToTime(const base::Value& value);

DictionaryPrefUpdate update(local_state, prefs::kAdBlockListSubscriptions);
base::DictionaryValue* subscriptions_dict = update.Get();
auto subscription_dict = base::Value(base::Value::Type::DICTIONARY);
subscription_dict.SetBoolKey("enabled", info.enabled);
subscription_dict.SetDoubleKey("last_update_attempt",
info.last_update_attempt.ToJsTime());
subscription_dict.SetDoubleKey(
"last_successful_update_attempt",
info.last_successful_update_attempt.ToJsTime());
subscription_dict.SetKey("last_update_attempt",
util::TimeToValue(info.last_update_attempt));
subscription_dict.SetKey("last_update_attempt",
util::TimeToValue(info.last_update_attempt));
subscriptions_dict->SetKey(id.spec(), std::move(subscription_dict));
}

Expand Down

0 comments on commit 1ab371c

Please sign in to comment.