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

Unified Diff: chrome/browser/extensions/api/messaging/message_service.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 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
Index: chrome/browser/extensions/api/messaging/message_service.cc
diff --git a/chrome/browser/extensions/api/messaging/message_service.cc b/chrome/browser/extensions/api/messaging/message_service.cc
index e19fc942520c2104e1308f2e33e3cd986bfbf608..507b7ef577811fe2191480d303d040d737578af8 100644
--- a/chrome/browser/extensions/api/messaging/message_service.cc
+++ b/chrome/browser/extensions/api/messaging/message_service.cc
@@ -127,16 +127,16 @@ const char kProhibitedByPoliciesError[] =
#endif
struct MessageService::MessageChannel {
- scoped_ptr<MessagePort> opener;
- scoped_ptr<MessagePort> receiver;
+ std::unique_ptr<MessagePort> opener;
+ std::unique_ptr<MessagePort> receiver;
};
struct MessageService::OpenChannelParams {
int source_process_id;
int source_routing_id;
- scoped_ptr<base::DictionaryValue> source_tab;
+ std::unique_ptr<base::DictionaryValue> source_tab;
int source_frame_id;
- scoped_ptr<MessagePort> receiver;
+ std::unique_ptr<MessagePort> receiver;
int receiver_port_id;
std::string source_extension_id;
std::string target_extension_id;
@@ -149,7 +149,7 @@ struct MessageService::OpenChannelParams {
// Takes ownership of receiver.
OpenChannelParams(int source_process_id,
int source_routing_id,
- scoped_ptr<base::DictionaryValue> source_tab,
+ std::unique_ptr<base::DictionaryValue> source_tab,
int source_frame_id,
MessagePort* receiver,
int receiver_port_id,
@@ -324,7 +324,7 @@ void MessageService::OpenChannelToExtension(
bool include_guest_process_info = false;
// Include info about the opener's tab (if it was a tab).
- scoped_ptr<base::DictionaryValue> source_tab;
+ std::unique_ptr<base::DictionaryValue> source_tab;
int source_frame_id = -1;
if (source_contents && ExtensionTabUtil::GetTabId(source_contents) >= 0) {
// Only the tab id is useful to platform apps for internal use. The
@@ -349,7 +349,7 @@ void MessageService::OpenChannelToExtension(
}
}
- scoped_ptr<OpenChannelParams> params(new OpenChannelParams(
+ std::unique_ptr<OpenChannelParams> params(new OpenChannelParams(
source_process_id, source_routing_id, std::move(source_tab),
source_frame_id, nullptr, receiver_port_id, source_extension_id,
target_extension_id, source_url, channel_name, include_tls_channel_id,
@@ -444,7 +444,7 @@ void MessageService::OpenChannelToNativeApp(
return;
}
- scoped_ptr<MessageChannel> channel(new MessageChannel());
+ std::unique_ptr<MessageChannel> channel(new MessageChannel());
channel->opener.reset(
new ExtensionMessagePort(weak_factory_.GetWeakPtr(),
GET_OPPOSITE_PORT_ID(receiver_port_id),
@@ -457,12 +457,9 @@ void MessageService::OpenChannelToNativeApp(
gfx::NativeView native_view = source ? source->GetNativeView() : nullptr;
std::string error = kReceivingEndDoesntExistError;
- scoped_ptr<NativeMessageHost> native_host = NativeMessageHost::Create(
- native_view,
- source_extension_id,
- native_app_name,
- policy_permission == ALLOW_ALL,
- &error);
+ std::unique_ptr<NativeMessageHost> native_host = NativeMessageHost::Create(
+ native_view, source_extension_id, native_app_name,
+ policy_permission == ALLOW_ALL, &error);
// Abandon the channel.
if (!native_host.get()) {
@@ -503,7 +500,7 @@ void MessageService::OpenChannelToTab(int source_process_id,
Profile::FromBrowserContext(source->GetProcess()->GetBrowserContext());
WebContents* contents = NULL;
- scoped_ptr<MessagePort> receiver;
+ std::unique_ptr<MessagePort> receiver;
if (!ExtensionTabUtil::GetTabById(tab_id, profile, true, NULL, NULL,
&contents, NULL) ||
contents->GetController().NeedsReload()) {
@@ -538,11 +535,11 @@ void MessageService::OpenChannelToTab(int source_process_id,
DCHECK(extension);
}
- scoped_ptr<OpenChannelParams> params(new OpenChannelParams(
- source_process_id,
- source_routing_id,
- scoped_ptr<base::DictionaryValue>(), // Source tab doesn't make sense
- // for opening to tabs.
+ std::unique_ptr<OpenChannelParams> params(new OpenChannelParams(
+ source_process_id, source_routing_id,
+ std::unique_ptr<base::DictionaryValue>(), // Source tab doesn't make
+ // sense
+ // for opening to tabs.
-1, // If there is no tab, then there is no frame either.
receiver.release(), receiver_port_id, extension_id, extension_id,
GURL(), // Source URL doesn't make sense for opening to tabs.
@@ -554,7 +551,7 @@ void MessageService::OpenChannelToTab(int source_process_id,
}
void MessageService::OpenChannelImpl(BrowserContext* browser_context,
- scoped_ptr<OpenChannelParams> params,
+ std::unique_ptr<OpenChannelParams> params,
const Extension* target_extension,
bool did_enqueue) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -572,7 +569,7 @@ void MessageService::OpenChannelImpl(BrowserContext* browser_context,
return;
}
- scoped_ptr<MessagePort> opener(
+ std::unique_ptr<MessagePort> opener(
new ExtensionMessagePort(weak_factory_.GetWeakPtr(),
GET_OPPOSITE_PORT_ID(params->receiver_port_id),
params->source_extension_id, source, false));
@@ -821,7 +818,7 @@ void MessageService::DispatchMessage(int source_port_id,
bool MessageService::MaybeAddPendingLazyBackgroundPageOpenChannelTask(
BrowserContext* context,
const Extension* extension,
- scoped_ptr<OpenChannelParams>* params,
+ std::unique_ptr<OpenChannelParams>* params,
const PendingMessagesQueue& pending_messages) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -853,8 +850,9 @@ bool MessageService::MaybeAddPendingLazyBackgroundPageOpenChannelTask(
return true;
}
-void MessageService::OnOpenChannelAllowed(scoped_ptr<OpenChannelParams> params,
- bool allowed) {
+void MessageService::OnOpenChannelAllowed(
+ std::unique_ptr<OpenChannelParams> params,
+ bool allowed) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
int channel_id = GET_CHANNEL_ID(params->receiver_port_id);
@@ -934,7 +932,7 @@ void MessageService::OnOpenChannelAllowed(scoped_ptr<OpenChannelParams> params,
}
}
-void MessageService::GotChannelID(scoped_ptr<OpenChannelParams> params,
+void MessageService::GotChannelID(std::unique_ptr<OpenChannelParams> params,
const std::string& tls_channel_id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -978,7 +976,7 @@ void MessageService::GotChannelID(scoped_ptr<OpenChannelParams> params,
}
void MessageService::PendingLazyBackgroundPageOpenChannel(
- scoped_ptr<OpenChannelParams> params,
+ std::unique_ptr<OpenChannelParams> params,
int source_process_id,
ExtensionHost* host) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);

Powered by Google App Engine
This is Rietveld 408576698