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

Unified Diff: chrome/browser/web_applications/web_app_mac.mm

Issue 2703283005: Destroy web_app::ShortcutInfo on UI thread (Closed)
Patch Set: s/auto/web_app::ShortcutInfo/. +Unretained. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/web_applications/web_app_mac.mm
diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm
index 1c467079d783e9788d418d0471d413cfa1770edc..f9e8fb43da8c0112c002e6da3e196c0f1b211b52 100644
--- a/chrome/browser/web_applications/web_app_mac.mm
+++ b/chrome/browser/web_applications/web_app_mac.mm
@@ -214,9 +214,8 @@ bool HasSameUserDataDir(const base::FilePath& bundle_path) {
user_data_dir.value(), base::CompareCase::SENSITIVE);
}
-void LaunchShimOnFileThread(
- std::unique_ptr<web_app::ShortcutInfo> shortcut_info,
- bool launched_after_rebuild) {
+void LaunchShimOnFileThread(web_app::ShortcutInfo* shortcut_info,
+ bool launched_after_rebuild) {
DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
base::FilePath shim_path = web_app::GetAppInstallPath(*shortcut_info);
@@ -265,19 +264,22 @@ void UpdatePlatformShortcutsInternal(
shortcut_creator.UpdateShortcuts();
}
-void UpdateAndLaunchShimOnFileThread(
- std::unique_ptr<web_app::ShortcutInfo> shortcut_info) {
+void UpdateAndLaunchShimOnFileThread(web_app::ShortcutInfo* shortcut_info) {
base::FilePath shortcut_data_dir = web_app::GetWebAppDataDirectory(
shortcut_info->profile_path, shortcut_info->extension_id, GURL());
UpdatePlatformShortcutsInternal(shortcut_data_dir, base::string16(),
*shortcut_info);
- LaunchShimOnFileThread(std::move(shortcut_info), true);
+ LaunchShimOnFileThread(shortcut_info, true);
}
void UpdateAndLaunchShim(std::unique_ptr<web_app::ShortcutInfo> shortcut_info) {
- content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE,
- base::Bind(&UpdateAndLaunchShimOnFileThread,
- base::Passed(&shortcut_info)));
+ web_app::ShortcutInfo* shortcut_info_ptr = shortcut_info.get();
+ content::BrowserThread::PostTaskAndReply(
+ content::BrowserThread::FILE, FROM_HERE,
+ base::Bind(&UpdateAndLaunchShimOnFileThread,
+ base::Unretained(shortcut_info_ptr)),
+ base::Bind(&web_app::internals::DeleteShortcutInfoOnUIThread,
+ base::Passed(&shortcut_info), base::Closure()));
}
void RebuildAppAndLaunch(std::unique_ptr<web_app::ShortcutInfo> shortcut_info) {
@@ -526,10 +528,9 @@ std::unique_ptr<web_app::ShortcutInfo> RecordAppShimErrorAndBuildShortcutInfo(
}
void RevealAppShimInFinderForAppOnFileThread(
- std::unique_ptr<web_app::ShortcutInfo> shortcut_info,
+ web_app::ShortcutInfo* shortcut_info,
const base::FilePath& app_path) {
- web_app::WebAppShortcutCreator shortcut_creator(app_path,
- shortcut_info.get());
+ web_app::WebAppShortcutCreator shortcut_creator(app_path, shortcut_info);
shortcut_creator.RevealAppShimInFinder();
}
@@ -977,9 +978,13 @@ void MaybeLaunchShortcut(std::unique_ptr<ShortcutInfo> shortcut_info) {
return;
}
- content::BrowserThread::PostTask(
+ web_app::ShortcutInfo* shortcut_info_ptr = shortcut_info.get();
+ content::BrowserThread::PostTaskAndReply(
content::BrowserThread::FILE, FROM_HERE,
- base::Bind(&LaunchShimOnFileThread, base::Passed(&shortcut_info), false));
+ base::Bind(&LaunchShimOnFileThread, base::Unretained(shortcut_info_ptr),
+ false),
+ base::Bind(&web_app::internals::DeleteShortcutInfoOnUIThread,
+ base::Passed(&shortcut_info), base::Closure()));
}
bool MaybeRebuildShortcut(const base::CommandLine& command_line) {
@@ -1022,37 +1027,39 @@ void RevealAppShimInFinderForApp(Profile* profile,
const extensions::Extension* app) {
std::unique_ptr<web_app::ShortcutInfo> shortcut_info =
ShortcutInfoForExtensionAndProfile(app, profile);
- content::BrowserThread::PostTask(
+ web_app::ShortcutInfo* shortcut_info_ptr = shortcut_info.get();
+ content::BrowserThread::PostTaskAndReply(
content::BrowserThread::FILE, FROM_HERE,
base::Bind(&RevealAppShimInFinderForAppOnFileThread,
- base::Passed(&shortcut_info), app->path()));
+ base::Unretained(shortcut_info_ptr), app->path()),
+ base::Bind(&web_app::internals::DeleteShortcutInfoOnUIThread,
+ base::Passed(&shortcut_info), base::Closure()));
}
namespace internals {
-bool CreatePlatformShortcuts(
- const base::FilePath& app_data_path,
- std::unique_ptr<ShortcutInfo> shortcut_info,
- const ShortcutLocations& creation_locations,
- ShortcutCreationReason creation_reason) {
+bool CreatePlatformShortcuts(const base::FilePath& app_data_path,
+ ShortcutInfo* shortcut_info,
+ const ShortcutLocations& creation_locations,
+ ShortcutCreationReason creation_reason) {
DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
if (AppShimsDisabledForTest())
return true;
- WebAppShortcutCreator shortcut_creator(app_data_path, shortcut_info.get());
+ WebAppShortcutCreator shortcut_creator(app_data_path, shortcut_info);
return shortcut_creator.CreateShortcuts(creation_reason, creation_locations);
}
void DeletePlatformShortcuts(const base::FilePath& app_data_path,
- std::unique_ptr<ShortcutInfo> shortcut_info) {
+ ShortcutInfo* shortcut_info) {
DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
- WebAppShortcutCreator shortcut_creator(app_data_path, shortcut_info.get());
+ WebAppShortcutCreator shortcut_creator(app_data_path, shortcut_info);
shortcut_creator.DeleteShortcuts();
}
void UpdatePlatformShortcuts(const base::FilePath& app_data_path,
const base::string16& old_app_title,
- std::unique_ptr<ShortcutInfo> shortcut_info) {
+ ShortcutInfo* shortcut_info) {
UpdatePlatformShortcutsInternal(app_data_path, old_app_title, *shortcut_info);
}

Powered by Google App Engine
This is Rietveld 408576698