Loading system/gd/btaa/attribution_processor.h +13 −0 Original line number Diff line number Diff line Loading @@ -82,7 +82,20 @@ class AttributionProcessor { void Dump( std::promise<flatbuffers::Offset<ActivityAttributionData>> promise, flatbuffers::FlatBufferBuilder* fb_builder); using ClockType = std::chrono::time_point<std::chrono::system_clock>; using NowFunc = ClockType (*)(); // by default, we use the std::chrono::system_clock::now implementation to // get the current timestamp AttributionProcessor() : now_func_(std::chrono::system_clock::now) {} // in other cases, we may need to use different implementation // e.g., for testing purposes AttributionProcessor(NowFunc func) : now_func_(func) {} private: // this function is added for testing support in // OnWakelockReleased NowFunc now_func_ = std::chrono::system_clock::now; bool wakeup_ = false; std::unordered_map<AddressActivityKey, BtaaAggregationEntry, AddressActivityKeyHasher> btaa_aggregator_; std::unordered_map<AddressActivityKey, BtaaAggregationEntry, AddressActivityKeyHasher> wakelock_duration_aggregator_; Loading system/gd/btaa/linux_generic/attribution_processor.cc +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ void AttributionProcessor::OnWakelockReleased(uint32_t duration_ms) { return; } auto cur_time = std::chrono::system_clock::now(); auto cur_time = now_func_(); for (auto& it : wakelock_duration_aggregator_) { it.second.wakelock_duration_ms = (uint64_t)duration_ms * it.second.byte_count / total_byte_count; if (btaa_aggregator_.find(it.first) == btaa_aggregator_.end()) { Loading Loading
system/gd/btaa/attribution_processor.h +13 −0 Original line number Diff line number Diff line Loading @@ -82,7 +82,20 @@ class AttributionProcessor { void Dump( std::promise<flatbuffers::Offset<ActivityAttributionData>> promise, flatbuffers::FlatBufferBuilder* fb_builder); using ClockType = std::chrono::time_point<std::chrono::system_clock>; using NowFunc = ClockType (*)(); // by default, we use the std::chrono::system_clock::now implementation to // get the current timestamp AttributionProcessor() : now_func_(std::chrono::system_clock::now) {} // in other cases, we may need to use different implementation // e.g., for testing purposes AttributionProcessor(NowFunc func) : now_func_(func) {} private: // this function is added for testing support in // OnWakelockReleased NowFunc now_func_ = std::chrono::system_clock::now; bool wakeup_ = false; std::unordered_map<AddressActivityKey, BtaaAggregationEntry, AddressActivityKeyHasher> btaa_aggregator_; std::unordered_map<AddressActivityKey, BtaaAggregationEntry, AddressActivityKeyHasher> wakelock_duration_aggregator_; Loading
system/gd/btaa/linux_generic/attribution_processor.cc +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ void AttributionProcessor::OnWakelockReleased(uint32_t duration_ms) { return; } auto cur_time = std::chrono::system_clock::now(); auto cur_time = now_func_(); for (auto& it : wakelock_duration_aggregator_) { it.second.wakelock_duration_ms = (uint64_t)duration_ms * it.second.byte_count / total_byte_count; if (btaa_aggregator_.find(it.first) == btaa_aggregator_.end()) { Loading