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

Unified Diff: extensions/browser/event_router.cc

Issue 1909773002: Convert //extensions/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . 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
« no previous file with comments | « extensions/browser/event_router.h ('k') | extensions/browser/event_router_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/event_router.cc
diff --git a/extensions/browser/event_router.cc b/extensions/browser/event_router.cc
index 0f56fe73906162c79954e2d72bb997f1d350299e..6cc2c7b647bcaeaa1a362a853d5b99fbd1ea5496 100644
--- a/extensions/browser/event_router.cc
+++ b/extensions/browser/event_router.cc
@@ -13,6 +13,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
@@ -62,7 +63,7 @@ const char kFilteredEvents[] = "filtered_events";
void NotifyEventDispatched(void* browser_context_id,
const std::string& extension_id,
const std::string& event_name,
- scoped_ptr<ListValue> args) {
+ std::unique_ptr<ListValue> args) {
// The ApiActivityMonitor can only be accessed from the UI thread.
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
@@ -113,7 +114,7 @@ void EventRouter::DispatchExtensionMessage(IPC::Sender* ipc_sender,
UserGestureState user_gesture,
const EventFilteringInfo& info) {
NotifyEventDispatched(browser_context_id, extension_id, event_name,
- make_scoped_ptr(event_args->DeepCopy()));
+ base::WrapUnique(event_args->DeepCopy()));
// TODO(chirantan): Make event dispatch a separate IPC so that it doesn't
// piggyback off MessageInvoke, which is used for other things.
@@ -132,7 +133,7 @@ void EventRouter::DispatchExtensionMessage(IPC::Sender* ipc_sender,
// DispatchExtensionMessage does _not_ take ownership of event_args, so we
// must ensure that the destruction of args does not attempt to free it.
- scoped_ptr<base::Value> removed_event_args;
+ std::unique_ptr<base::Value> removed_event_args;
args.Remove(1, &removed_event_args);
ignore_result(removed_event_args.release());
}
@@ -154,7 +155,7 @@ void EventRouter::DispatchEventToSender(IPC::Sender* ipc_sender,
const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<ListValue> event_args,
+ std::unique_ptr<ListValue> event_args,
UserGestureState user_gesture,
const EventFilteringInfo& info) {
int event_id = g_extension_event_id.GetNext();
@@ -199,14 +200,14 @@ void EventRouter::AddEventListener(const std::string& event_name,
content::RenderProcessHost* process,
const std::string& extension_id) {
listeners_.AddListener(EventListener::ForExtension(
- event_name, extension_id, process, scoped_ptr<DictionaryValue>()));
+ event_name, extension_id, process, std::unique_ptr<DictionaryValue>()));
}
void EventRouter::RemoveEventListener(const std::string& event_name,
content::RenderProcessHost* process,
const std::string& extension_id) {
- scoped_ptr<EventListener> listener = EventListener::ForExtension(
- event_name, extension_id, process, scoped_ptr<DictionaryValue>());
+ std::unique_ptr<EventListener> listener = EventListener::ForExtension(
+ event_name, extension_id, process, std::unique_ptr<DictionaryValue>());
listeners_.RemoveListener(listener.get());
}
@@ -214,14 +215,14 @@ void EventRouter::AddEventListenerForURL(const std::string& event_name,
content::RenderProcessHost* process,
const GURL& listener_url) {
listeners_.AddListener(EventListener::ForURL(
- event_name, listener_url, process, scoped_ptr<DictionaryValue>()));
+ event_name, listener_url, process, std::unique_ptr<DictionaryValue>()));
}
void EventRouter::RemoveEventListenerForURL(const std::string& event_name,
content::RenderProcessHost* process,
const GURL& listener_url) {
- scoped_ptr<EventListener> listener = EventListener::ForURL(
- event_name, listener_url, process, scoped_ptr<DictionaryValue>());
+ std::unique_ptr<EventListener> listener = EventListener::ForURL(
+ event_name, listener_url, process, std::unique_ptr<DictionaryValue>());
listeners_.RemoveListener(listener.get());
}
@@ -289,7 +290,7 @@ void EventRouter::RenderProcessHostDestroyed(content::RenderProcessHost* host) {
void EventRouter::AddLazyEventListener(const std::string& event_name,
const std::string& extension_id) {
bool is_new = listeners_.AddListener(EventListener::ForExtension(
- event_name, extension_id, NULL, scoped_ptr<DictionaryValue>()));
+ event_name, extension_id, NULL, std::unique_ptr<DictionaryValue>()));
if (is_new) {
std::set<std::string> events = GetRegisteredEvents(extension_id);
@@ -301,8 +302,8 @@ void EventRouter::AddLazyEventListener(const std::string& event_name,
void EventRouter::RemoveLazyEventListener(const std::string& event_name,
const std::string& extension_id) {
- scoped_ptr<EventListener> listener = EventListener::ForExtension(
- event_name, extension_id, NULL, scoped_ptr<DictionaryValue>());
+ std::unique_ptr<EventListener> listener = EventListener::ForExtension(
+ event_name, extension_id, NULL, std::unique_ptr<DictionaryValue>());
bool did_exist = listeners_.RemoveListener(listener.get());
if (did_exist) {
@@ -319,17 +320,13 @@ void EventRouter::AddFilteredEventListener(const std::string& event_name,
const base::DictionaryValue& filter,
bool add_lazy_listener) {
listeners_.AddListener(EventListener::ForExtension(
- event_name,
- extension_id,
- process,
- scoped_ptr<DictionaryValue>(filter.DeepCopy())));
+ event_name, extension_id, process,
+ std::unique_ptr<DictionaryValue>(filter.DeepCopy())));
if (add_lazy_listener) {
bool added = listeners_.AddListener(EventListener::ForExtension(
- event_name,
- extension_id,
- NULL,
- scoped_ptr<DictionaryValue>(filter.DeepCopy())));
+ event_name, extension_id, NULL,
+ std::unique_ptr<DictionaryValue>(filter.DeepCopy())));
if (added)
AddFilterToEvent(event_name, extension_id, &filter);
@@ -342,11 +339,9 @@ void EventRouter::RemoveFilteredEventListener(
const std::string& extension_id,
const base::DictionaryValue& filter,
bool remove_lazy_listener) {
- scoped_ptr<EventListener> listener = EventListener::ForExtension(
- event_name,
- extension_id,
- process,
- scoped_ptr<DictionaryValue>(filter.DeepCopy()));
+ std::unique_ptr<EventListener> listener = EventListener::ForExtension(
+ event_name, extension_id, process,
+ std::unique_ptr<DictionaryValue>(filter.DeepCopy()));
listeners_.RemoveListener(listener.get());
@@ -465,18 +460,18 @@ const DictionaryValue* EventRouter::GetFilteredEvents(
return events;
}
-void EventRouter::BroadcastEvent(scoped_ptr<Event> event) {
+void EventRouter::BroadcastEvent(std::unique_ptr<Event> event) {
DispatchEventImpl(std::string(), linked_ptr<Event>(event.release()));
}
void EventRouter::DispatchEventToExtension(const std::string& extension_id,
- scoped_ptr<Event> event) {
+ std::unique_ptr<Event> event) {
DCHECK(!extension_id.empty());
DispatchEventImpl(extension_id, linked_ptr<Event>(event.release()));
}
void EventRouter::DispatchEventWithLazyListener(const std::string& extension_id,
- scoped_ptr<Event> event) {
+ std::unique_ptr<Event> event) {
DCHECK(!extension_id.empty());
std::string event_name = event->event_name;
bool has_listener = ExtensionHasEventListener(extension_id, event_name);
@@ -858,12 +853,12 @@ void EventRouter::OnExtensionUnloaded(content::BrowserContext* browser_context,
Event::Event(events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> event_args)
+ std::unique_ptr<base::ListValue> event_args)
: Event(histogram_value, event_name, std::move(event_args), nullptr) {}
Event::Event(events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> event_args,
+ std::unique_ptr<base::ListValue> event_args,
BrowserContext* restrict_to_browser_context)
: Event(histogram_value,
event_name,
@@ -875,7 +870,7 @@ Event::Event(events::HistogramValue histogram_value,
Event::Event(events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<ListValue> event_args_tmp,
+ std::unique_ptr<ListValue> event_args_tmp,
BrowserContext* restrict_to_browser_context,
const GURL& event_url,
EventRouter::UserGestureState user_gesture,
@@ -899,10 +894,10 @@ Event::Event(events::HistogramValue histogram_value,
Event::~Event() {}
Event* Event::DeepCopy() {
- Event* copy = new Event(histogram_value, event_name,
- scoped_ptr<base::ListValue>(event_args->DeepCopy()),
- restrict_to_browser_context, event_url, user_gesture,
- filter_info);
+ Event* copy = new Event(
+ histogram_value, event_name,
+ std::unique_ptr<base::ListValue>(event_args->DeepCopy()),
+ restrict_to_browser_context, event_url, user_gesture, filter_info);
copy->will_dispatch_callback = will_dispatch_callback;
return copy;
}
« no previous file with comments | « extensions/browser/event_router.h ('k') | extensions/browser/event_router_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698