| 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..77ca6ba572453feac4d76ed9e142ff1ccd7414df 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,14 @@ class ImageFamily;
|
| namespace web_app {
|
|
|
| // Represents the info required to create a shortcut for an app.
|
| -struct ShortcutInfo {
|
| +// ShortcutInfo is passed around via scoped_refptrs, and is destroyed on UI
|
| +// thread. Since gfx::ImageFamily can have gfx::Image and it has ImageStorage
|
| +// which has a non-thread-safe ref count bound to UI thread, all ref count
|
| +// manipulation must happen on UI thread.
|
| +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,9 +65,11 @@ struct ShortcutInfo {
|
| std::string version_for_display;
|
|
|
| private:
|
| - // ShortcutInfo must not be copied; generally it is passed around via
|
| - // scoped_ptrs. This is to allow passing ShortcutInfos between threads,
|
| - // despite ImageFamily having a non-thread-safe reference count.
|
| + friend struct content::BrowserThread::DeleteOnThread<
|
| + content::BrowserThread::UI>;
|
| + friend class base::DeleteHelper<ShortcutInfo>;
|
| + ~ShortcutInfo();
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(ShortcutInfo);
|
| };
|
|
|
| @@ -106,12 +116,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 +131,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 +177,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 +238,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.
|
|
|