Commit 509a0418 authored by avi's avatar avi Committed by Commit bot

Switch SupportsUserData uses to use unique_ptr.

The interface taking a raw pointer is deprecated and being removed.

BUG=690937

Review-Url: https://codereview.chromium.org/2845263002
Cr-Commit-Position: refs/heads/master@{#468031}
parent 716a1363
...@@ -17,6 +17,8 @@ namespace task_manager { ...@@ -17,6 +17,8 @@ namespace task_manager {
// service. // service.
class BackgroundContentsTag : public WebContentsTag { class BackgroundContentsTag : public WebContentsTag {
public: public:
~BackgroundContentsTag() override;
// task_manager::WebContentsTag: // task_manager::WebContentsTag:
BackgroundContentsTask* CreateTask() const override; BackgroundContentsTask* CreateTask() const override;
...@@ -25,7 +27,6 @@ class BackgroundContentsTag : public WebContentsTag { ...@@ -25,7 +27,6 @@ class BackgroundContentsTag : public WebContentsTag {
BackgroundContentsTag(content::WebContents* web_contents, BackgroundContentsTag(content::WebContents* web_contents,
BackgroundContents* background_contents); BackgroundContents* background_contents);
~BackgroundContentsTag() override;
// The owning BackgroundContents. // The owning BackgroundContents.
BackgroundContents* background_contents_; BackgroundContents* background_contents_;
......
...@@ -14,6 +14,8 @@ namespace task_manager { ...@@ -14,6 +14,8 @@ namespace task_manager {
// Defines a concrete UserData type for WebContents owned by DevToolsWindow. // Defines a concrete UserData type for WebContents owned by DevToolsWindow.
class DevToolsTag : public WebContentsTag { class DevToolsTag : public WebContentsTag {
public: public:
~DevToolsTag() override;
// task_manager::WebContentsTag: // task_manager::WebContentsTag:
DevToolsTask* CreateTask() const override; DevToolsTask* CreateTask() const override;
...@@ -21,7 +23,6 @@ class DevToolsTag : public WebContentsTag { ...@@ -21,7 +23,6 @@ class DevToolsTag : public WebContentsTag {
friend class WebContentsTags; friend class WebContentsTags;
explicit DevToolsTag(content::WebContents* web_contents); explicit DevToolsTag(content::WebContents* web_contents);
~DevToolsTag() override;
DISALLOW_COPY_AND_ASSIGN(DevToolsTag); DISALLOW_COPY_AND_ASSIGN(DevToolsTag);
}; };
......
...@@ -14,6 +14,8 @@ namespace task_manager { ...@@ -14,6 +14,8 @@ namespace task_manager {
// Defines a concrete UserData type for WebContents owned by extensions. // Defines a concrete UserData type for WebContents owned by extensions.
class ExtensionTag : public WebContentsTag { class ExtensionTag : public WebContentsTag {
public: public:
~ExtensionTag() override;
// task_manager::WebContentsTag: // task_manager::WebContentsTag:
ExtensionTask* CreateTask() const override; ExtensionTask* CreateTask() const override;
...@@ -22,7 +24,6 @@ class ExtensionTag : public WebContentsTag { ...@@ -22,7 +24,6 @@ class ExtensionTag : public WebContentsTag {
ExtensionTag(content::WebContents* web_contents, ExtensionTag(content::WebContents* web_contents,
const extensions::ViewType view_type); const extensions::ViewType view_type);
~ExtensionTag() override;
// The ViewType of the extension WebContents this tag is attached to. // The ViewType of the extension WebContents this tag is attached to.
const extensions::ViewType view_type_; const extensions::ViewType view_type_;
......
...@@ -15,6 +15,8 @@ namespace task_manager { ...@@ -15,6 +15,8 @@ namespace task_manager {
// which represents browser <*view> tag plugin guests. // which represents browser <*view> tag plugin guests.
class GuestTag : public WebContentsTag { class GuestTag : public WebContentsTag {
public: public:
~GuestTag() override;
// task_manager::WebContentsTag: // task_manager::WebContentsTag:
GuestTask* CreateTask() const override; GuestTask* CreateTask() const override;
...@@ -22,7 +24,6 @@ class GuestTag : public WebContentsTag { ...@@ -22,7 +24,6 @@ class GuestTag : public WebContentsTag {
friend class WebContentsTags; friend class WebContentsTags;
explicit GuestTag(content::WebContents* web_contents); explicit GuestTag(content::WebContents* web_contents);
~GuestTag() override;
DISALLOW_COPY_AND_ASSIGN(GuestTag); DISALLOW_COPY_AND_ASSIGN(GuestTag);
}; };
......
...@@ -15,6 +15,8 @@ namespace task_manager { ...@@ -15,6 +15,8 @@ namespace task_manager {
// PrerenderManager. // PrerenderManager.
class PrerenderTag : public WebContentsTag { class PrerenderTag : public WebContentsTag {
public: public:
~PrerenderTag() override;
// task_manager::WebContentsTag: // task_manager::WebContentsTag:
PrerenderTask* CreateTask() const override; PrerenderTask* CreateTask() const override;
...@@ -22,7 +24,6 @@ class PrerenderTag : public WebContentsTag { ...@@ -22,7 +24,6 @@ class PrerenderTag : public WebContentsTag {
friend class WebContentsTags; friend class WebContentsTags;
explicit PrerenderTag(content::WebContents* web_contents); explicit PrerenderTag(content::WebContents* web_contents);
~PrerenderTag() override;
DISALLOW_COPY_AND_ASSIGN(PrerenderTag); DISALLOW_COPY_AND_ASSIGN(PrerenderTag);
}; };
......
...@@ -15,6 +15,8 @@ namespace task_manager { ...@@ -15,6 +15,8 @@ namespace task_manager {
// and background printing. // and background printing.
class PrintingTag : public WebContentsTag { class PrintingTag : public WebContentsTag {
public: public:
~PrintingTag() override;
// task_manager::WebContentsTag: // task_manager::WebContentsTag:
PrintingTask* CreateTask() const override; PrintingTask* CreateTask() const override;
...@@ -22,7 +24,6 @@ class PrintingTag : public WebContentsTag { ...@@ -22,7 +24,6 @@ class PrintingTag : public WebContentsTag {
friend class WebContentsTags; friend class WebContentsTags;
explicit PrintingTag(content::WebContents* web_contents); explicit PrintingTag(content::WebContents* web_contents);
~PrintingTag() override;
DISALLOW_COPY_AND_ASSIGN(PrintingTag); DISALLOW_COPY_AND_ASSIGN(PrintingTag);
}; };
......
...@@ -14,6 +14,8 @@ namespace task_manager { ...@@ -14,6 +14,8 @@ namespace task_manager {
// Defines a concrete UserData type for WebContents owned by the TabStripModel. // Defines a concrete UserData type for WebContents owned by the TabStripModel.
class TabContentsTag : public WebContentsTag { class TabContentsTag : public WebContentsTag {
public: public:
~TabContentsTag() override;
// task_manager::WebContentsTag: // task_manager::WebContentsTag:
TabContentsTask* CreateTask() const override; TabContentsTask* CreateTask() const override;
...@@ -21,7 +23,6 @@ class TabContentsTag : public WebContentsTag { ...@@ -21,7 +23,6 @@ class TabContentsTag : public WebContentsTag {
friend class WebContentsTags; friend class WebContentsTags;
explicit TabContentsTag(content::WebContents* web_contents); explicit TabContentsTag(content::WebContents* web_contents);
~TabContentsTag() override;
DISALLOW_COPY_AND_ASSIGN(TabContentsTag); DISALLOW_COPY_AND_ASSIGN(TabContentsTag);
}; };
......
...@@ -25,6 +25,8 @@ class RendererTask; ...@@ -25,6 +25,8 @@ class RendererTask;
// |task_manager::WebContentsTags|. // |task_manager::WebContentsTags|.
class WebContentsTag : public base::SupportsUserData::Data { class WebContentsTag : public base::SupportsUserData::Data {
public: public:
~WebContentsTag() override;
// Retrieves the instance of the WebContentsTag that was attached to the // Retrieves the instance of the WebContentsTag that was attached to the
// specified WebContents and returns it. If no instance was attached, returns // specified WebContents and returns it. If no instance was attached, returns
// nullptr. // nullptr.
...@@ -45,7 +47,6 @@ class WebContentsTag : public base::SupportsUserData::Data { ...@@ -45,7 +47,6 @@ class WebContentsTag : public base::SupportsUserData::Data {
friend class WebContentsTags; friend class WebContentsTags;
explicit WebContentsTag(content::WebContents* contents); explicit WebContentsTag(content::WebContents* contents);
~WebContentsTag() override;
private: private:
// The user data key. // The user data key.
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "chrome/browser/task_manager/web_contents_tags.h" #include "chrome/browser/task_manager/web_contents_tags.h"
#include <memory>
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/task_manager/providers/web_contents/background_contents_tag.h" #include "chrome/browser/task_manager/providers/web_contents/background_contents_tag.h"
#include "chrome/browser/task_manager/providers/web_contents/devtools_tag.h" #include "chrome/browser/task_manager/providers/web_contents/devtools_tag.h"
...@@ -32,13 +34,14 @@ namespace { ...@@ -32,13 +34,14 @@ namespace {
// |WebContentsTagsManager|. // |WebContentsTagsManager|.
// Note: This will fail if |contents| is already tagged by |tag|. // Note: This will fail if |contents| is already tagged by |tag|.
void TagWebContents(content::WebContents* contents, void TagWebContents(content::WebContents* contents,
WebContentsTag* tag, std::unique_ptr<WebContentsTag> tag,
void* tag_key) { void* tag_key) {
DCHECK(contents); DCHECK(contents);
DCHECK(tag); DCHECK(tag);
DCHECK(WebContentsTag::FromWebContents(contents) == nullptr); DCHECK(WebContentsTag::FromWebContents(contents) == nullptr);
contents->SetUserData(tag_key, tag); WebContentsTag* tag_ptr = tag.get();
WebContentsTagsManager::GetInstance()->AddTag(tag); contents->SetUserData(tag_key, std::move(tag));
WebContentsTagsManager::GetInstance()->AddTag(tag_ptr);
} }
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)
...@@ -67,10 +70,10 @@ void WebContentsTags::CreateForBackgroundContents( ...@@ -67,10 +70,10 @@ void WebContentsTags::CreateForBackgroundContents(
BackgroundContents* background_contents) { BackgroundContents* background_contents) {
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
if (!WebContentsTag::FromWebContents(web_contents)) { if (!WebContentsTag::FromWebContents(web_contents)) {
TagWebContents( TagWebContents(web_contents,
web_contents, base::WrapUnique(new BackgroundContentsTag(
new BackgroundContentsTag(web_contents, background_contents), web_contents, background_contents)),
WebContentsTag::kTagKey); WebContentsTag::kTagKey);
} }
#endif // !defined(OS_ANDROID) #endif // !defined(OS_ANDROID)
} }
...@@ -81,7 +84,7 @@ void WebContentsTags::CreateForDevToolsContents( ...@@ -81,7 +84,7 @@ void WebContentsTags::CreateForDevToolsContents(
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
if (!WebContentsTag::FromWebContents(web_contents)) { if (!WebContentsTag::FromWebContents(web_contents)) {
TagWebContents(web_contents, TagWebContents(web_contents,
new DevToolsTag(web_contents), base::WrapUnique(new DevToolsTag(web_contents)),
WebContentsTag::kTagKey); WebContentsTag::kTagKey);
} }
#endif // !defined(OS_ANDROID) #endif // !defined(OS_ANDROID)
...@@ -93,7 +96,7 @@ void WebContentsTags::CreateForPrerenderContents( ...@@ -93,7 +96,7 @@ void WebContentsTags::CreateForPrerenderContents(
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
if (!WebContentsTag::FromWebContents(web_contents)) { if (!WebContentsTag::FromWebContents(web_contents)) {
TagWebContents(web_contents, TagWebContents(web_contents,
new PrerenderTag(web_contents), base::WrapUnique(new PrerenderTag(web_contents)),
WebContentsTag::kTagKey); WebContentsTag::kTagKey);
} }
#endif // !defined(OS_ANDROID) #endif // !defined(OS_ANDROID)
...@@ -104,7 +107,7 @@ void WebContentsTags::CreateForTabContents(content::WebContents* web_contents) { ...@@ -104,7 +107,7 @@ void WebContentsTags::CreateForTabContents(content::WebContents* web_contents) {
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
if (!WebContentsTag::FromWebContents(web_contents)) { if (!WebContentsTag::FromWebContents(web_contents)) {
TagWebContents(web_contents, TagWebContents(web_contents,
new TabContentsTag(web_contents), base::WrapUnique(new TabContentsTag(web_contents)),
WebContentsTag::kTagKey); WebContentsTag::kTagKey);
} }
#endif // !defined(OS_ANDROID) #endif // !defined(OS_ANDROID)
...@@ -116,7 +119,7 @@ void WebContentsTags::CreateForPrintingContents( ...@@ -116,7 +119,7 @@ void WebContentsTags::CreateForPrintingContents(
#if !defined(OS_ANDROID) && BUILDFLAG(ENABLE_PRINT_PREVIEW) #if !defined(OS_ANDROID) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (!WebContentsTag::FromWebContents(web_contents)) { if (!WebContentsTag::FromWebContents(web_contents)) {
TagWebContents(web_contents, TagWebContents(web_contents,
new PrintingTag(web_contents), base::WrapUnique(new PrintingTag(web_contents)),
WebContentsTag::kTagKey); WebContentsTag::kTagKey);
} }
#endif // !defined(OS_ANDROID) && BUILDFLAG(ENABLE_PRINT_PREVIEW) #endif // !defined(OS_ANDROID) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
...@@ -128,8 +131,7 @@ void WebContentsTags::CreateForGuestContents( ...@@ -128,8 +131,7 @@ void WebContentsTags::CreateForGuestContents(
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
DCHECK(guest_view::GuestViewBase::IsGuest(web_contents)); DCHECK(guest_view::GuestViewBase::IsGuest(web_contents));
if (!WebContentsTag::FromWebContents(web_contents)) { if (!WebContentsTag::FromWebContents(web_contents)) {
TagWebContents(web_contents, TagWebContents(web_contents, base::WrapUnique(new GuestTag(web_contents)),
new GuestTag(web_contents),
WebContentsTag::kTagKey); WebContentsTag::kTagKey);
} }
#endif // !defined(OS_ANDROID) #endif // !defined(OS_ANDROID)
...@@ -143,7 +145,7 @@ void WebContentsTags::CreateForExtension(content::WebContents* web_contents, ...@@ -143,7 +145,7 @@ void WebContentsTags::CreateForExtension(content::WebContents* web_contents,
if (!WebContentsTag::FromWebContents(web_contents)) { if (!WebContentsTag::FromWebContents(web_contents)) {
TagWebContents(web_contents, TagWebContents(web_contents,
new ExtensionTag(web_contents, view_type), base::WrapUnique(new ExtensionTag(web_contents, view_type)),
WebContentsTag::kTagKey); WebContentsTag::kTagKey);
} }
#endif // !defined(OS_ANDROID) && BUILDFLAG(ENABLE_EXTENSIONS) #endif // !defined(OS_ANDROID) && BUILDFLAG(ENABLE_EXTENSIONS)
......
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