Index: chrome/browser/web_applications/web_app.h |
diff --git a/chrome/browser/web_applications/web_app.h b/chrome/browser/web_applications/web_app.h |
index 1e4234920bfc7d50a934120ed5b8d6a01a645c23..eabec3783f66e54ca2c0c6d5eaa5004af5272dc2 100644 |
--- a/chrome/browser/web_applications/web_app.h |
+++ b/chrome/browser/web_applications/web_app.h |
@@ -12,10 +12,13 @@ |
#include "base/callback.h" |
#include "base/files/file_path.h" |
#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/sequenced_task_runner_helpers.h" |
#include "base/strings/string16.h" |
#include "build/build_config.h" |
#include "chrome/browser/shell_integration.h" |
#include "chrome/common/web_application_info.h" |
+#include "content/public/browser/browser_thread.h" |
class Profile; |
@@ -37,9 +40,10 @@ class ImageFamily; |
namespace web_app { |
// Represents the info required to create a shortcut for an app. |
-struct ShortcutInfo { |
+struct ShortcutInfo : public base::RefCountedThreadSafe< |
+ ShortcutInfo, |
+ content::BrowserThread::DeleteOnUIThread> { |
ShortcutInfo(); |
- ~ShortcutInfo(); |
GURL url; |
// If |extension_id| is non-empty, this is short cut is to an extension-app |
@@ -57,8 +61,13 @@ struct ShortcutInfo { |
std::string version_for_display; |
private: |
+ friend struct content::BrowserThread::DeleteOnThread< |
+ content::BrowserThread::UI>; |
+ friend class base::DeleteHelper<ShortcutInfo>; |
+ ~ShortcutInfo(); |
+ |
// ShortcutInfo must not be copied; generally it is passed around via |
- // scoped_ptrs. This is to allow passing ShortcutInfos between threads, |
+ // scoped_refptrs. This is to allow passing ShortcutInfos between threads, |
// despite ImageFamily having a non-thread-safe reference count. |
tapted
2017/02/28 23:30:06
I suggest moving this up to a class comment, with
tzik
2017/03/01 05:31:34
Acknowledged.
tzik
2017/03/01 05:32:30
Done.
|
DISALLOW_COPY_AND_ASSIGN(ShortcutInfo); |
}; |
@@ -106,12 +115,11 @@ enum ShortcutCreationReason { |
}; |
// Called by GetShortcutInfoForApp after fetching the ShortcutInfo. |
-typedef base::Callback<void(std::unique_ptr<ShortcutInfo>)> |
- ShortcutInfoCallback; |
+typedef base::Callback<void(scoped_refptr<ShortcutInfo>)> ShortcutInfoCallback; |
#if defined(TOOLKIT_VIEWS) |
// Extracts shortcut info of the given WebContents. |
-std::unique_ptr<ShortcutInfo> GetShortcutInfoForTab( |
+scoped_refptr<ShortcutInfo> GetShortcutInfoForTab( |
content::WebContents* web_contents); |
#endif |
@@ -122,7 +130,7 @@ std::unique_ptr<ShortcutInfo> GetShortcutInfoForTab( |
// updates (recreates) them if they exits. |
void UpdateShortcutForTabContents(content::WebContents* web_contents); |
-std::unique_ptr<ShortcutInfo> ShortcutInfoForExtensionAndProfile( |
+scoped_refptr<ShortcutInfo> ShortcutInfoForExtensionAndProfile( |
const extensions::Extension* app, |
Profile* profile); |
@@ -168,7 +176,7 @@ std::string GetExtensionIdFromApplicationName(const std::string& app_name); |
// |locations| contains information about where to create them. |
void CreateShortcutsWithInfo(ShortcutCreationReason reason, |
const ShortcutLocations& locations, |
- std::unique_ptr<ShortcutInfo> shortcut_info); |
+ scoped_refptr<ShortcutInfo> shortcut_info); |
// Creates shortcuts for an app. This loads the app's icon from disk, and calls |
// CreateShortcutsWithInfo(). If you already have a ShortcutInfo with the app's |
@@ -229,24 +237,23 @@ std::vector<base::FilePath> GetShortcutPaths( |
// shortcut, and is also used as the UserDataDir for platform app shortcuts. |
// |shortcut_info| contains info about the shortcut to create, and |
// |creation_locations| contains information about where to create them. |
-bool CreatePlatformShortcuts( |
- const base::FilePath& shortcut_data_path, |
- std::unique_ptr<ShortcutInfo> shortcut_info, |
- const ShortcutLocations& creation_locations, |
- ShortcutCreationReason creation_reason); |
+bool CreatePlatformShortcuts(const base::FilePath& shortcut_data_path, |
+ scoped_refptr<ShortcutInfo> shortcut_info, |
+ const ShortcutLocations& creation_locations, |
+ ShortcutCreationReason creation_reason); |
// Delete all the shortcuts we have added for this extension. This is the |
// platform specific implementation of the DeleteAllShortcuts function, and |
// is executed on the FILE thread. |
void DeletePlatformShortcuts(const base::FilePath& shortcut_data_path, |
- std::unique_ptr<ShortcutInfo> shortcut_info); |
+ scoped_refptr<ShortcutInfo> shortcut_info); |
// Updates all the shortcuts we have added for this extension. This is the |
// platform specific implementation of the UpdateAllShortcuts function, and |
// is executed on the FILE thread. |
void UpdatePlatformShortcuts(const base::FilePath& shortcut_data_path, |
const base::string16& old_app_title, |
- std::unique_ptr<ShortcutInfo> shortcut_info); |
+ scoped_refptr<ShortcutInfo> shortcut_info); |
// Delete all the shortcuts for an entire profile. |
// This is executed on the FILE thread. |