[local_ads] review fixes

This commit is contained in:
Arsentiy Milchakov 2017-12-19 14:25:40 +03:00 committed by Roman Kuznetsov
parent 9d7092946a
commit cb2c892088
5 changed files with 19 additions and 19 deletions

View file

@ -167,8 +167,9 @@ void Statistics::Startup()
SendToServer();
};
auto const recursiveAsyncTask = [asyncTask]
auto const recursiveAsyncTask = [this, asyncTask]
{
IndexMetadata();
asyncTask();
GetPlatform().RunDelayedTask(Platform::Thread::File, kSendingTimeout, asyncTask);
};
@ -494,7 +495,7 @@ void Statistics::CleanupAfterTesting()
GetPlatform().RmDirRecursively(statsFolder);
}
void Statistics::SetCustomServerSerializer(ServerSerializer && serializer)
void Statistics::SetCustomServerSerializer(ServerSerializer const & serializer)
{
GetPlatform().RunTask(Platform::Thread::File,
[this, serializer] { m_serverSerializer = serializer; });

View file

@ -9,7 +9,6 @@
#include <functional>
#include <list>
#include <map>
#include <mutex>
#include <string>
#include <vector>
@ -38,7 +37,7 @@ public:
void SetUserId(std::string const & userId);
void SetCustomServerSerializer(ServerSerializer && serializer);
void SetCustomServerSerializer(ServerSerializer const & serializer);
void RegisterEvent(Event && event);
void RegisterEvents(std::list<Event> && events);

View file

@ -472,9 +472,7 @@ Framework::Framework(FrameworkParams const & params)
// Local ads manager should be initialized after storage initialization.
if (params.m_enableLocalAds)
{
m_localAdsManager.Startup(m_bmManager.get());
}
m_routingManager.SetRouterImpl(RouterType::Vehicle);
@ -1834,8 +1832,7 @@ void Framework::DestroyDrapeEngine()
m_trafficManager.SetDrapeEngine(nullptr);
m_localAdsManager.SetDrapeEngine(nullptr);
m_searchMarks.SetDrapeEngine(nullptr);
m_bmManager.SetDrapeEngine(nullptr);
m_localAdsManager.SetDrapeEngine(nullptr);
GetBookmarkManager().SetDrapeEngine(nullptr);
m_trafficManager.Teardown();
GpsTracker::Instance().Disconnect();

View file

@ -403,29 +403,32 @@ bool LocalAdsManager::DownloadCampaign(MwmSet::MwmId const & mwmId, std::vector<
return true;
}
void LocalAdsManager::ProcessRequests(std::set<Request> const & campaignMwms)
void LocalAdsManager::ProcessRequests(std::set<Request> const & requests)
{
std::string const campaignFile = GetPath(kCampaignFile);
for (auto const & mwm : campaignMwms)
for (auto const & request : requests)
{
if (!mwm.first.IsAlive())
auto const & mwm = request.first;
auto const & type = request.second;
if (!mwm.IsAlive())
continue;
std::string const countryName = mwm.first.GetInfo()->GetCountryName();
if (mwm.second == RequestType::Download)
std::string const countryName = mwm.GetInfo()->GetCountryName();
if (type == RequestType::Download)
{
// Download campaign data from server.
CampaignInfo info;
info.m_created = local_ads::Clock::now();
if (!DownloadCampaign(mwm.first, info.m_data))
if (!DownloadCampaign(mwm, info.m_data))
continue;
// Parse data and recreate marks.
ClearLocalAdsForMwm(mwm.first);
ClearLocalAdsForMwm(mwm);
if (!info.m_data.empty())
{
auto campaignData = ParseCampaign(std::move(info.m_data), mwm.first, info.m_created);
auto campaignData = ParseCampaign(std::move(info.m_data), mwm, info.m_created);
if (!campaignData.empty())
{
UpdateFeaturesCache(ReadCampaignFeatures(m_readFeaturesFn, campaignData));
@ -436,11 +439,11 @@ void LocalAdsManager::ProcessRequests(std::set<Request> const & campaignMwms)
m_campaigns[countryName] = true;
m_info[countryName] = info;
}
else if (mwm.second == RequestType::Delete)
else if (type == RequestType::Delete)
{
m_campaigns.erase(countryName);
m_info.erase(countryName);
ClearLocalAdsForMwm(mwm.first);
ClearLocalAdsForMwm(mwm);
}
}

View file

@ -286,7 +286,7 @@ public:
m_networkThread.PushDelayed(delay, forward<Task>(task));
break;
case Thread::Gui:
ASSERT(false, ("Delayed tasks for gui thread are not supported yet"));
CHECK(false, ("Delayed tasks for gui thread are not supported yet"));
break;
}
}