Commit bd675444 authored by nancylingwang's avatar nancylingwang Committed by Commit Bot

Bind a weak ptr for the search result to resolve the crash issue.

The icon callback may outlive ArcAppShortcutSearchResult, so bind the
callback to a weak ptr.

BUG=1114754

Change-Id: If261827920d5a4780a80695095937a9f7dd59c5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2348492Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796845}
parent d2629b45
...@@ -50,12 +50,12 @@ ArcAppShortcutSearchResult::ArcAppShortcutSearchResult( ...@@ -50,12 +50,12 @@ ArcAppShortcutSearchResult::ArcAppShortcutSearchResult(
apps::ArcRawIconPngDataToImageSkia( apps::ArcRawIconPngDataToImageSkia(
std::move(data_->icon), icon_dimension, std::move(data_->icon), icon_dimension,
base::BindOnce(&ArcAppShortcutSearchResult::SetIcon, base::BindOnce(&ArcAppShortcutSearchResult::SetIcon,
base::Unretained(this))); weak_ptr_factory_.GetWeakPtr()));
} else if (data_->icon && data_->icon->icon_png_data && } else if (data_->icon && data_->icon->icon_png_data &&
!data_->icon->icon_png_data->empty()) { !data_->icon->icon_png_data->empty()) {
icon_decode_request_ = std::make_unique<arc::IconDecodeRequest>( icon_decode_request_ = std::make_unique<arc::IconDecodeRequest>(
base::BindOnce(&ArcAppShortcutSearchResult::SetIcon, base::BindOnce(&ArcAppShortcutSearchResult::SetIcon,
base::Unretained(this)), weak_ptr_factory_.GetWeakPtr()),
icon_dimension); icon_dimension);
icon_decode_request_->StartWithOptions(data_->icon->icon_png_data.value()); icon_decode_request_->StartWithOptions(data_->icon->icon_png_data.value());
} else { } else {
...@@ -63,7 +63,7 @@ ArcAppShortcutSearchResult::ArcAppShortcutSearchResult( ...@@ -63,7 +63,7 @@ ArcAppShortcutSearchResult::ArcAppShortcutSearchResult(
// OS. // OS.
icon_decode_request_ = std::make_unique<arc::IconDecodeRequest>( icon_decode_request_ = std::make_unique<arc::IconDecodeRequest>(
base::BindOnce(&ArcAppShortcutSearchResult::SetIcon, base::BindOnce(&ArcAppShortcutSearchResult::SetIcon,
base::Unretained(this)), weak_ptr_factory_.GetWeakPtr()),
icon_dimension); icon_dimension);
icon_decode_request_->StartWithOptions(data_->icon_png); icon_decode_request_->StartWithOptions(data_->icon_png);
} }
......
...@@ -59,6 +59,8 @@ class ArcAppShortcutSearchResult : public ChromeSearchResult, ...@@ -59,6 +59,8 @@ class ArcAppShortcutSearchResult : public ChromeSearchResult,
Profile* const profile_; // Owned by ProfileInfo. Profile* const profile_; // Owned by ProfileInfo.
AppListControllerDelegate* const list_controller_; // Owned by AppListClient. AppListControllerDelegate* const list_controller_; // Owned by AppListClient.
base::WeakPtrFactory<ArcAppShortcutSearchResult> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ArcAppShortcutSearchResult); DISALLOW_COPY_AND_ASSIGN(ArcAppShortcutSearchResult);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment