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

Unified Diff: chrome/browser/web_applications/web_app.cc

Issue 2721553002: Make web_app::ShortcutInfo RefCountedThreadSafe (1) (Closed)
Patch Set: TestBrowserThreadBundle for mac test fix 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.cc
diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc
index d0da8543b40f3381214cef41238a0f50b9bd3003..358db3f2a8d098cff9aedccce420bd56266a092c 100644
--- a/chrome/browser/web_applications/web_app.cc
+++ b/chrome/browser/web_applications/web_app.cc
@@ -88,11 +88,11 @@ base::FilePath GetShortcutDataDir(const web_app::ShortcutInfo& shortcut_info) {
void UpdateAllShortcutsForShortcutInfo(
const base::string16& old_app_title,
const base::Closure& callback,
- std::unique_ptr<web_app::ShortcutInfo> shortcut_info) {
+ scoped_refptr<web_app::ShortcutInfo> shortcut_info) {
base::FilePath shortcut_data_dir = GetShortcutDataDir(*shortcut_info);
- base::Closure task = base::Bind(&web_app::internals::UpdatePlatformShortcuts,
- shortcut_data_dir, old_app_title,
- base::Passed(&shortcut_info));
+ base::Closure task =
+ base::Bind(&web_app::internals::UpdatePlatformShortcuts,
+ shortcut_data_dir, old_app_title, std::move(shortcut_info));
if (callback.is_null()) {
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, task);
} else {
@@ -101,7 +101,7 @@ void UpdateAllShortcutsForShortcutInfo(
}
}
-void OnImageLoaded(std::unique_ptr<web_app::ShortcutInfo> shortcut_info,
+void OnImageLoaded(scoped_refptr<web_app::ShortcutInfo> shortcut_info,
web_app::ShortcutInfoCallback callback,
const gfx::ImageFamily& image_family) {
// If the image failed to load (e.g. if the resource being loaded was empty)
@@ -128,13 +128,13 @@ void OnImageLoaded(std::unique_ptr<web_app::ShortcutInfo> shortcut_info,
void ScheduleCreatePlatformShortcut(
web_app::ShortcutCreationReason reason,
const web_app::ShortcutLocations& locations,
- std::unique_ptr<web_app::ShortcutInfo> shortcut_info) {
+ scoped_refptr<web_app::ShortcutInfo> shortcut_info) {
base::FilePath shortcut_data_dir = GetShortcutDataDir(*shortcut_info);
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(
base::IgnoreResult(&web_app::internals::CreatePlatformShortcuts),
- shortcut_data_dir, base::Passed(&shortcut_info), locations, reason));
+ shortcut_data_dir, std::move(shortcut_info), locations, reason));
}
} // namespace
@@ -173,7 +173,7 @@ ShortcutLocations::ShortcutLocations()
}
#if defined(TOOLKIT_VIEWS)
-std::unique_ptr<ShortcutInfo> GetShortcutInfoForTab(
+scoped_refptr<ShortcutInfo> GetShortcutInfoForTab(
content::WebContents* web_contents) {
const favicon::FaviconDriver* favicon_driver =
favicon::ContentFaviconDriver::FromWebContents(web_contents);
@@ -181,7 +181,7 @@ std::unique_ptr<ShortcutInfo> GetShortcutInfoForTab(
extensions::TabHelper::FromWebContents(web_contents);
const WebApplicationInfo& app_info = extensions_tab_helper->web_app_info();
- std::unique_ptr<ShortcutInfo> info(new ShortcutInfo);
+ scoped_refptr<ShortcutInfo> info(new ShortcutInfo);
info->url = app_info.app_url.is_empty() ? web_contents->GetURL() :
app_info.app_url;
info->title = app_info.title.empty() ?
@@ -203,10 +203,10 @@ std::unique_ptr<ShortcutInfo> GetShortcutInfoForTab(
void UpdateShortcutForTabContents(content::WebContents* web_contents) {}
#endif
-std::unique_ptr<ShortcutInfo> ShortcutInfoForExtensionAndProfile(
+scoped_refptr<ShortcutInfo> ShortcutInfoForExtensionAndProfile(
const extensions::Extension* app,
Profile* profile) {
- std::unique_ptr<ShortcutInfo> shortcut_info(new ShortcutInfo);
+ scoped_refptr<ShortcutInfo> shortcut_info(new ShortcutInfo);
shortcut_info->extension_id = app->id();
shortcut_info->is_platform_app = app->is_platform_app();
@@ -230,7 +230,7 @@ std::unique_ptr<ShortcutInfo> ShortcutInfoForExtensionAndProfile(
void GetShortcutInfoForApp(const extensions::Extension* extension,
Profile* profile,
const ShortcutInfoCallback& callback) {
- std::unique_ptr<web_app::ShortcutInfo> shortcut_info(
+ scoped_refptr<web_app::ShortcutInfo> shortcut_info(
web_app::ShortcutInfoForExtensionAndProfile(extension, profile));
std::vector<extensions::ImageLoader::ImageRepresentation> info_list;
@@ -386,7 +386,7 @@ std::string GetExtensionIdFromApplicationName(const std::string& app_name) {
void CreateShortcutsWithInfo(ShortcutCreationReason reason,
const ShortcutLocations& locations,
- std::unique_ptr<ShortcutInfo> shortcut_info) {
+ scoped_refptr<ShortcutInfo> shortcut_info) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// If the shortcut is for an application shortcut with the new bookmark app
@@ -427,7 +427,7 @@ void CreateShortcuts(ShortcutCreationReason reason,
void DeleteAllShortcuts(Profile* profile, const extensions::Extension* app) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- std::unique_ptr<ShortcutInfo> shortcut_info(
+ scoped_refptr<ShortcutInfo> shortcut_info(
ShortcutInfoForExtensionAndProfile(app, profile));
base::FilePath shortcut_data_dir = GetShortcutDataDir(*shortcut_info);
BrowserThread::PostTask(

Powered by Google App Engine
This is Rietveld 408576698