Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: components/arc/intent_helper/activity_icon_loader.cc

Issue 2655213004: Avoid retaining a reference to ActivityIconLoader in its OnIconReady() (Closed)
Patch Set: +-DCHECK(thread_checker_.COVT()); Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/arc/intent_helper/activity_icon_loader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/intent_helper/activity_icon_loader.cc
diff --git a/components/arc/intent_helper/activity_icon_loader.cc b/components/arc/intent_helper/activity_icon_loader.cc
index d83b6a1da1bca4c3641d31da24959ae96be20d1b..715b6bd8db8fb25b16490d613c3390e06b122770 100644
--- a/components/arc/intent_helper/activity_icon_loader.cc
+++ b/components/arc/intent_helper/activity_icon_loader.cc
@@ -77,6 +77,7 @@ ActivityIconLoader::ActivityIconLoader()
ActivityIconLoader::~ActivityIconLoader() {}
void ActivityIconLoader::InvalidateIcons(const std::string& package_name) {
+ DCHECK(thread_checker_.CalledOnValidThread());
for (auto it = cached_icons_.begin(); it != cached_icons_.end();) {
if (it->first.package_name == package_name)
it = cached_icons_.erase(it);
@@ -88,6 +89,7 @@ void ActivityIconLoader::InvalidateIcons(const std::string& package_name) {
ActivityIconLoader::GetResult ActivityIconLoader::GetActivityIcons(
const std::vector<ActivityName>& activities,
const OnIconsReadyCallback& cb) {
+ DCHECK(thread_checker_.CalledOnValidThread());
std::unique_ptr<ActivityToIconsMap> result(new ActivityToIconsMap);
std::vector<mojom::ActivityNamePtr> activities_to_fetch;
@@ -160,20 +162,20 @@ void ActivityIconLoader::OnIconsReady(
std::unique_ptr<ActivityToIconsMap> cached_result,
const OnIconsReadyCallback& cb,
std::vector<mojom::ActivityIconPtr> icons) {
+ DCHECK(thread_checker_.CalledOnValidThread());
ArcServiceManager* manager = ArcServiceManager::Get();
base::PostTaskAndReplyWithResult(
manager->blocking_task_runner().get(), FROM_HERE,
- base::Bind(&ActivityIconLoader::ResizeAndEncodeIcons, this,
+ base::Bind(&ActivityIconLoader::ResizeAndEncodeIcons,
base::Passed(&icons)),
base::Bind(&ActivityIconLoader::OnIconsResized, this,
base::Passed(&cached_result), cb));
}
+// static
std::unique_ptr<ActivityIconLoader::ActivityToIconsMap>
ActivityIconLoader::ResizeAndEncodeIcons(
std::vector<mojom::ActivityIconPtr> icons) {
- // Runs only on the blocking pool.
- DCHECK(thread_checker_.CalledOnValidThread());
std::unique_ptr<ActivityToIconsMap> result(new ActivityToIconsMap);
for (size_t i = 0; i < icons.size(); ++i) {
@@ -229,6 +231,7 @@ void ActivityIconLoader::OnIconsResized(
std::unique_ptr<ActivityToIconsMap> cached_result,
const OnIconsReadyCallback& cb,
std::unique_ptr<ActivityToIconsMap> result) {
+ DCHECK(thread_checker_.CalledOnValidThread());
// Update |cached_icons_|.
for (const auto& kv : *result) {
cached_icons_.erase(kv.first);
« no previous file with comments | « components/arc/intent_helper/activity_icon_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698