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

Side by Side Diff: components/arc/intent_helper/activity_icon_loader.cc

Issue 2655213004: Avoid retaining a reference to ActivityIconLoader in its OnIconReady() (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/arc/intent_helper/activity_icon_loader.h" 5 #include "components/arc/intent_helper/activity_icon_loader.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <tuple> 9 #include <tuple>
10 #include <utility> 10 #include <utility>
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return true; 156 return true;
157 } 157 }
158 158
159 void ActivityIconLoader::OnIconsReady( 159 void ActivityIconLoader::OnIconsReady(
160 std::unique_ptr<ActivityToIconsMap> cached_result, 160 std::unique_ptr<ActivityToIconsMap> cached_result,
161 const OnIconsReadyCallback& cb, 161 const OnIconsReadyCallback& cb,
162 std::vector<mojom::ActivityIconPtr> icons) { 162 std::vector<mojom::ActivityIconPtr> icons) {
163 ArcServiceManager* manager = ArcServiceManager::Get(); 163 ArcServiceManager* manager = ArcServiceManager::Get();
164 base::PostTaskAndReplyWithResult( 164 base::PostTaskAndReplyWithResult(
165 manager->blocking_task_runner().get(), FROM_HERE, 165 manager->blocking_task_runner().get(), FROM_HERE,
166 base::Bind(&ActivityIconLoader::ResizeAndEncodeIcons, this, 166 base::Bind(&ActivityIconLoader::ResizeAndEncodeIcons,
hidehiko 2017/01/26 13:14:20 (I know it is not your mistake, but ...) ResizeAn
tzik 2017/01/26 13:21:12 Done.
167 base::Passed(&icons)), 167 base::Unretained(this), base::Passed(&icons)),
168 base::Bind(&ActivityIconLoader::OnIconsResized, this, 168 base::Bind(&ActivityIconLoader::OnIconsResized, this,
169 base::Passed(&cached_result), cb)); 169 base::Passed(&cached_result), cb));
170 } 170 }
171 171
172 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> 172 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap>
173 ActivityIconLoader::ResizeAndEncodeIcons( 173 ActivityIconLoader::ResizeAndEncodeIcons(
174 std::vector<mojom::ActivityIconPtr> icons) { 174 std::vector<mojom::ActivityIconPtr> icons) {
175 // Runs only on the blocking pool. 175 // Runs only on the blocking pool.
176 DCHECK(thread_checker_.CalledOnValidThread()); 176 DCHECK(thread_checker_.CalledOnValidThread());
177 std::unique_ptr<ActivityToIconsMap> result(new ActivityToIconsMap); 177 std::unique_ptr<ActivityToIconsMap> result(new ActivityToIconsMap);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 cached_icons_.erase(kv.first); 234 cached_icons_.erase(kv.first);
235 cached_icons_.insert(std::make_pair(kv.first, kv.second)); 235 cached_icons_.insert(std::make_pair(kv.first, kv.second));
236 } 236 }
237 237
238 // Merge the results that were obtained from cache before doing IPC. 238 // Merge the results that were obtained from cache before doing IPC.
239 result->insert(cached_result->begin(), cached_result->end()); 239 result->insert(cached_result->begin(), cached_result->end());
240 cb.Run(std::move(result)); 240 cb.Run(std::move(result));
241 } 241 }
242 242
243 } // namespace arc 243 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698