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

Unified Diff: chrome/browser/extensions/event_router_forwarder.cc

Issue 10694085: Refactor extension event distribution to use Values instead of JSON strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing memory leak in a test. Created 8 years, 4 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/event_router_forwarder.cc
diff --git a/chrome/browser/extensions/event_router_forwarder.cc b/chrome/browser/extensions/event_router_forwarder.cc
index d44a5f4640a218298a99f5b8cd278e00fc7947a0..adeb033c775ed46611b6cb6c1be01fd90e45aae1 100644
--- a/chrome/browser/extensions/event_router_forwarder.cc
+++ b/chrome/browser/extensions/event_router_forwarder.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "base/bind.h"
+#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -22,47 +23,47 @@ EventRouterForwarder::~EventRouterForwarder() {
void EventRouterForwarder::BroadcastEventToRenderers(
const std::string& event_name,
- const std::string& event_args,
+ scoped_ptr<base::ListValue> event_args,
const GURL& event_url) {
- HandleEvent("", event_name, event_args, 0, true, event_url);
+ HandleEvent("", event_name, event_args.Pass(), 0, true, event_url);
}
void EventRouterForwarder::DispatchEventToRenderers(
const std::string& event_name,
- const std::string& event_args,
+ scoped_ptr<base::ListValue> event_args,
void* profile,
bool use_profile_to_restrict_events,
const GURL& event_url) {
if (!profile)
return;
- HandleEvent("", event_name, event_args, profile,
+ HandleEvent("", event_name, event_args.Pass(), profile,
use_profile_to_restrict_events, event_url);
}
void EventRouterForwarder::BroadcastEventToExtension(
const std::string& extension_id,
const std::string& event_name,
- const std::string& event_args,
+ scoped_ptr<base::ListValue> event_args,
const GURL& event_url) {
- HandleEvent(extension_id, event_name, event_args, 0, true, event_url);
+ HandleEvent(extension_id, event_name, event_args.Pass(), 0, true, event_url);
}
void EventRouterForwarder::DispatchEventToExtension(
const std::string& extension_id,
const std::string& event_name,
- const std::string& event_args,
+ scoped_ptr<base::ListValue> event_args,
void* profile,
bool use_profile_to_restrict_events,
const GURL& event_url) {
if (!profile)
return;
- HandleEvent(extension_id, event_name, event_args, profile,
+ HandleEvent(extension_id, event_name, event_args.Pass(), profile,
use_profile_to_restrict_events, event_url);
}
void EventRouterForwarder::HandleEvent(const std::string& extension_id,
const std::string& event_name,
- const std::string& event_args,
+ scoped_ptr<ListValue> event_args,
void* profile_ptr,
bool use_profile_to_restrict_events,
const GURL& event_url) {
@@ -70,7 +71,7 @@ void EventRouterForwarder::HandleEvent(const std::string& extension_id,
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&EventRouterForwarder::HandleEvent, this,
- extension_id, event_name, event_args, profile_ptr,
+ extension_id, event_name, Passed(&event_args), profile_ptr,
use_profile_to_restrict_events, event_url));
return;
}
@@ -86,13 +87,13 @@ void EventRouterForwarder::HandleEvent(const std::string& extension_id,
return;
}
if (profile) {
- CallEventRouter(profile, extension_id, event_name, event_args,
+ CallEventRouter(profile, extension_id, event_name, event_args.Pass(),
use_profile_to_restrict_events ? profile : NULL, event_url);
} else {
std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles());
for (size_t i = 0; i < profiles.size(); ++i) {
CallEventRouter(
- profiles[i], extension_id, event_name, event_args,
+ profiles[i], extension_id, event_name, event_args.Pass(),
use_profile_to_restrict_events ? profiles[i] : NULL, event_url);
}
}
@@ -101,7 +102,7 @@ void EventRouterForwarder::HandleEvent(const std::string& extension_id,
void EventRouterForwarder::CallEventRouter(Profile* profile,
const std::string& extension_id,
const std::string& event_name,
- const std::string& event_args,
+ scoped_ptr<ListValue> event_args,
Profile* restrict_to_profile,
const GURL& event_url) {
// We may not have an extension in cases like chromeos login
@@ -113,13 +114,13 @@ void EventRouterForwarder::CallEventRouter(Profile* profile,
if (extension_id.empty()) {
profile->GetExtensionEventRouter()->
DispatchEventToRenderers(
- event_name, event_args, restrict_to_profile, event_url,
+ event_name, event_args.Pass(), restrict_to_profile, event_url,
EventFilteringInfo());
} else {
profile->GetExtensionEventRouter()->
DispatchEventToExtension(
extension_id,
- event_name, event_args, restrict_to_profile, event_url);
+ event_name, event_args.Pass(), restrict_to_profile, event_url);
}
}
« no previous file with comments | « chrome/browser/extensions/event_router_forwarder.h ('k') | chrome/browser/extensions/event_router_forwarder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698