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

Unified Diff: chrome/renderer/extensions/event_bindings.cc

Issue 10024055: Remove unneeded extension_messages_browsertest.cc + cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: windoooowze Created 8 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/renderer/extensions/event_bindings.cc
diff --git a/chrome/renderer/extensions/event_bindings.cc b/chrome/renderer/extensions/event_bindings.cc
index 6aec2c4986e93f275050c9d204ed762f21f535c8..478c7f2f28008c3d887197d09e1d944b7f3c2642 100644
--- a/chrome/renderer/extensions/event_bindings.cc
+++ b/chrome/renderer/extensions/event_bindings.cc
@@ -77,21 +77,20 @@ class ExtensionImpl : public ChromeV8Extension {
event_name))
return v8::Undefined();
+ std::string extension_id = context->GetExtensionID();
EventListenerCounts& listener_counts =
- g_listener_counts.Get()[context->extension_id()];
+ g_listener_counts.Get()[extension_id];
if (++listener_counts[event_name] == 1) {
content::RenderThread::Get()->Send(
- new ExtensionHostMsg_AddListener(context->extension_id(),
- event_name));
+ new ExtensionHostMsg_AddListener(extension_id, event_name));
}
// This is called the first time the page has added a listener. Since
// the background page is the only lazy page, we know this is the first
// time this listener has been registered.
- if (self->IsLazyBackgroundPage(context->extension_id())) {
+ if (self->IsLazyBackgroundPage(context->extension())) {
content::RenderThread::Get()->Send(
- new ExtensionHostMsg_AddLazyListener(context->extension_id(),
- event_name));
+ new ExtensionHostMsg_AddLazyListener(extension_id, event_name));
}
}
@@ -111,25 +110,24 @@ class ExtensionImpl : public ChromeV8Extension {
if (!context)
return v8::Undefined();
+ std::string extension_id = context->GetExtensionID();
EventListenerCounts& listener_counts =
- g_listener_counts.Get()[context->extension_id()];
+ g_listener_counts.Get()[extension_id];
std::string event_name(*v8::String::AsciiValue(args[0]));
bool is_manual = args[1]->BooleanValue();
if (--listener_counts[event_name] == 0) {
content::RenderThread::Get()->Send(
- new ExtensionHostMsg_RemoveListener(context->extension_id(),
- event_name));
+ new ExtensionHostMsg_RemoveListener(extension_id, event_name));
}
// DetachEvent is called when the last listener for the context is
// removed. If the context is the background page, and it removes the
// last listener manually, then we assume that it is no longer interested
// in being awakened for this event.
- if (is_manual && self->IsLazyBackgroundPage(context->extension_id())) {
+ if (is_manual && self->IsLazyBackgroundPage(context->extension())) {
content::RenderThread::Get()->Send(
- new ExtensionHostMsg_RemoveLazyListener(context->extension_id(),
- event_name));
+ new ExtensionHostMsg_RemoveLazyListener(extension_id, event_name));
}
}
@@ -138,14 +136,12 @@ class ExtensionImpl : public ChromeV8Extension {
private:
- bool IsLazyBackgroundPage(const std::string& extension_id) {
+ bool IsLazyBackgroundPage(const Extension* extension) {
content::RenderView* render_view = GetCurrentRenderView();
if (!render_view)
return false;
ExtensionHelper* helper = ExtensionHelper::Get(render_view);
- const ::Extension* extension =
- extension_dispatcher()->extensions()->GetByID(extension_id);
return (extension && extension->has_lazy_background_page() &&
helper->view_type() == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
}
« no previous file with comments | « chrome/renderer/extensions/chrome_v8_context_set_unittest.cc ('k') | chrome/renderer/extensions/extension_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698