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

Side by Side Diff: chrome/browser/extensions/extension_event_router.h

Issue 8343079: Don't close background pages if there is a pending response (callback). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_event_router.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // If |cross_incognito_profile| is non-NULL and different from 81 // If |cross_incognito_profile| is non-NULL and different from
82 // restrict_to_profile, send the event with cross_incognito_args to the 82 // restrict_to_profile, send the event with cross_incognito_args to the
83 // extensions in that profile that can't cross incognito. 83 // extensions in that profile that can't cross incognito.
84 void DispatchEventsToRenderersAcrossIncognito( 84 void DispatchEventsToRenderersAcrossIncognito(
85 const std::string& event_name, 85 const std::string& event_name,
86 const std::string& event_args, 86 const std::string& event_args,
87 Profile* restrict_to_profile, 87 Profile* restrict_to_profile,
88 const std::string& cross_incognito_args, 88 const std::string& cross_incognito_args,
89 const GURL& event_url); 89 const GURL& event_url);
90 90
91 // Record the Event Ack from the renderer. (One less event in-flight.)
92 void OnExtensionEventAck(const std::string& extension_id);
93
94 // Check if there are any Extension Events that have not yet been acked by
95 // the renderer.
96 bool HasInFlightEvents(const std::string& extension_id);
97
91 protected: 98 protected:
92 // The details of an event to be dispatched. 99 // The details of an event to be dispatched.
93 struct ExtensionEvent; 100 struct ExtensionEvent;
94 101
95 // Shared by DispatchEvent*. If |extension_id| is empty, the event is 102 // Shared by DispatchEvent*. If |extension_id| is empty, the event is
96 // broadcast. 103 // broadcast.
97 // An event that just came off the pending list may not be delayed again. 104 // An event that just came off the pending list may not be delayed again.
98 void DispatchEventImpl(const linked_ptr<ExtensionEvent>& event, 105 void DispatchEventImpl(const linked_ptr<ExtensionEvent>& event,
99 bool was_pending); 106 bool was_pending);
100 107
(...skipping 24 matching lines...) Expand all
125 typedef std::map<std::string, std::set<EventListener> > ListenerMap; 132 typedef std::map<std::string, std::set<EventListener> > ListenerMap;
126 ListenerMap listeners_; 133 ListenerMap listeners_;
127 134
128 // A map between an extension id and the queue of events pending 135 // A map between an extension id and the queue of events pending
129 // the load of it's background page. 136 // the load of it's background page.
130 typedef std::vector<linked_ptr<ExtensionEvent> > PendingEventsList; 137 typedef std::vector<linked_ptr<ExtensionEvent> > PendingEventsList;
131 typedef std::map<std::string, 138 typedef std::map<std::string,
132 linked_ptr<PendingEventsList> > PendingEventsPerExtMap; 139 linked_ptr<PendingEventsList> > PendingEventsPerExtMap;
133 PendingEventsPerExtMap pending_events_; 140 PendingEventsPerExtMap pending_events_;
134 141
142 // Track of the number of dispatched events that have not yet sent an
143 // ACK from the renderer.
144 void IncrementInFlightEvents(const std::string& extension_id);
145 std::map<std::string, int> in_flight_events_;
146
135 DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouter); 147 DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouter);
136 }; 148 };
137 149
138 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ 150 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698