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

Unified Diff: chrome/browser/task_manager/web_contents_tags.cc

Issue 2845263002: Switch SupportsUserData uses to use unique_ptr. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « chrome/browser/task_manager/providers/web_contents/web_contents_tag.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/task_manager/web_contents_tags.cc
diff --git a/chrome/browser/task_manager/web_contents_tags.cc b/chrome/browser/task_manager/web_contents_tags.cc
index ce2f04bd1825d37a8dbbbddf33910fa5e5e0e6f0..a9c16fd8a34929f092e6c8b7b58399a573999144 100644
--- a/chrome/browser/task_manager/web_contents_tags.cc
+++ b/chrome/browser/task_manager/web_contents_tags.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/task_manager/web_contents_tags.h"
+#include <memory>
+
#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/devtools_tag.h"
@@ -32,13 +34,14 @@ namespace {
// |WebContentsTagsManager|.
// Note: This will fail if |contents| is already tagged by |tag|.
void TagWebContents(content::WebContents* contents,
- WebContentsTag* tag,
+ std::unique_ptr<WebContentsTag> tag,
void* tag_key) {
DCHECK(contents);
DCHECK(tag);
DCHECK(WebContentsTag::FromWebContents(contents) == nullptr);
- contents->SetUserData(tag_key, tag);
- WebContentsTagsManager::GetInstance()->AddTag(tag);
+ WebContentsTag* tag_ptr = tag.get();
+ contents->SetUserData(tag_key, std::move(tag));
+ WebContentsTagsManager::GetInstance()->AddTag(tag_ptr);
}
#if BUILDFLAG(ENABLE_EXTENSIONS)
@@ -67,10 +70,10 @@ void WebContentsTags::CreateForBackgroundContents(
BackgroundContents* background_contents) {
#if !defined(OS_ANDROID)
if (!WebContentsTag::FromWebContents(web_contents)) {
- TagWebContents(
- web_contents,
- new BackgroundContentsTag(web_contents, background_contents),
- WebContentsTag::kTagKey);
+ TagWebContents(web_contents,
+ base::WrapUnique(new BackgroundContentsTag(
+ web_contents, background_contents)),
+ WebContentsTag::kTagKey);
}
#endif // !defined(OS_ANDROID)
}
@@ -81,7 +84,7 @@ void WebContentsTags::CreateForDevToolsContents(
#if !defined(OS_ANDROID)
if (!WebContentsTag::FromWebContents(web_contents)) {
TagWebContents(web_contents,
- new DevToolsTag(web_contents),
+ base::WrapUnique(new DevToolsTag(web_contents)),
WebContentsTag::kTagKey);
}
#endif // !defined(OS_ANDROID)
@@ -93,7 +96,7 @@ void WebContentsTags::CreateForPrerenderContents(
#if !defined(OS_ANDROID)
if (!WebContentsTag::FromWebContents(web_contents)) {
TagWebContents(web_contents,
- new PrerenderTag(web_contents),
+ base::WrapUnique(new PrerenderTag(web_contents)),
WebContentsTag::kTagKey);
}
#endif // !defined(OS_ANDROID)
@@ -104,7 +107,7 @@ void WebContentsTags::CreateForTabContents(content::WebContents* web_contents) {
#if !defined(OS_ANDROID)
if (!WebContentsTag::FromWebContents(web_contents)) {
TagWebContents(web_contents,
- new TabContentsTag(web_contents),
+ base::WrapUnique(new TabContentsTag(web_contents)),
WebContentsTag::kTagKey);
}
#endif // !defined(OS_ANDROID)
@@ -116,7 +119,7 @@ void WebContentsTags::CreateForPrintingContents(
#if !defined(OS_ANDROID) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (!WebContentsTag::FromWebContents(web_contents)) {
TagWebContents(web_contents,
- new PrintingTag(web_contents),
+ base::WrapUnique(new PrintingTag(web_contents)),
WebContentsTag::kTagKey);
}
#endif // !defined(OS_ANDROID) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
@@ -128,8 +131,7 @@ void WebContentsTags::CreateForGuestContents(
#if !defined(OS_ANDROID)
DCHECK(guest_view::GuestViewBase::IsGuest(web_contents));
if (!WebContentsTag::FromWebContents(web_contents)) {
- TagWebContents(web_contents,
- new GuestTag(web_contents),
+ TagWebContents(web_contents, base::WrapUnique(new GuestTag(web_contents)),
WebContentsTag::kTagKey);
}
#endif // !defined(OS_ANDROID)
@@ -143,7 +145,7 @@ void WebContentsTags::CreateForExtension(content::WebContents* web_contents,
if (!WebContentsTag::FromWebContents(web_contents)) {
TagWebContents(web_contents,
- new ExtensionTag(web_contents, view_type),
+ base::WrapUnique(new ExtensionTag(web_contents, view_type)),
WebContentsTag::kTagKey);
}
#endif // !defined(OS_ANDROID) && BUILDFLAG(ENABLE_EXTENSIONS)
« no previous file with comments | « chrome/browser/task_manager/providers/web_contents/web_contents_tag.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698