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

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

Issue 2655233007: Get rid of RefCounted for ActivityIconLoader. (Closed)
Patch Set: address comments 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/arc_service_manager.cc ('k') | components/arc/intent_helper/activity_icon_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/intent_helper/activity_icon_loader.h
diff --git a/components/arc/intent_helper/activity_icon_loader.h b/components/arc/intent_helper/activity_icon_loader.h
index 58b78925f742f6f6f9376befe5ad1068925c4165..b182fac07452afe2b2b62805569f76ea3773ced5 100644
--- a/components/arc/intent_helper/activity_icon_loader.h
+++ b/components/arc/intent_helper/activity_icon_loader.h
@@ -13,18 +13,19 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "components/arc/arc_service.h"
#include "components/arc/common/intent_helper.mojom.h"
-#include "components/arc/intent_helper/arc_intent_helper_bridge.h"
#include "ui/base/layout.h"
#include "ui/gfx/image/image.h"
#include "url/gurl.h"
namespace arc {
+namespace internal {
// A class which retrieves an activity icon from ARC.
-class ActivityIconLoader : public base::RefCounted<ActivityIconLoader> {
+class ActivityIconLoader {
public:
struct Icons {
Icons(const gfx::Image& icon16, const gfx::Image& icon20,
@@ -69,6 +70,7 @@ class ActivityIconLoader : public base::RefCounted<ActivityIconLoader> {
base::Callback<void(std::unique_ptr<ActivityToIconsMap>)>;
ActivityIconLoader();
+ ~ActivityIconLoader();
// Removes icons associated with |package_name| from the cache.
void InvalidateIcons(const std::string& package_name);
@@ -92,18 +94,11 @@ class ActivityIconLoader : public base::RefCounted<ActivityIconLoader> {
const ActivityToIconsMap& cached_icons_for_testing() { return cached_icons_; }
private:
- friend class base::RefCounted<ActivityIconLoader>;
- ~ActivityIconLoader();
-
// A function called when the mojo IPC returns.
void OnIconsReady(std::unique_ptr<ActivityToIconsMap> cached_result,
const OnIconsReadyCallback& cb,
std::vector<mojom::ActivityIconPtr> icons);
- // Resizes and encodes |icons| and returns the results as ActivityToIconsMap.
- static std::unique_ptr<ActivityToIconsMap> ResizeAndEncodeIcons(
- std::vector<mojom::ActivityIconPtr> icons);
-
// A function called when ResizeIcons finishes. Append items in |result| to
// |cached_icons_|.
void OnIconsResized(std::unique_ptr<ActivityToIconsMap> cached_result,
@@ -117,9 +112,13 @@ class ActivityIconLoader : public base::RefCounted<ActivityIconLoader> {
base::ThreadChecker thread_checker_;
+ // This must come last to make sure weak pointers are invalidated first.
+ base::WeakPtrFactory<ActivityIconLoader> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(ActivityIconLoader);
};
+} // namespace internal
} // namespace arc
#endif // COMPONENTS_ARC_INTENT_HELPER_ACTIVITY_ICON_LOADER_H_
« no previous file with comments | « components/arc/arc_service_manager.cc ('k') | components/arc/intent_helper/activity_icon_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698