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

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

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, 2 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 | « chrome/renderer/extensions/extension_process_bindings.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/extension_process_bindings.cc
diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc
index 5472dce03cb0b510566aa2431b667eecde6865e7..c1aa392ec2ef07f16ce53f9f891f86a7a65ccbbb 100644
--- a/chrome/renderer/extensions/extension_process_bindings.cc
+++ b/chrome/renderer/extensions/extension_process_bindings.cc
@@ -66,11 +66,13 @@ const char* kExtensionDeps[] = {
// Contains info relevant to a pending API request.
struct PendingRequest {
public :
- PendingRequest(v8::Persistent<v8::Context> context, const std::string& name)
- : context(context), name(name) {
+ PendingRequest(v8::Persistent<v8::Context> context, const std::string& name,
+ const std::string& extension_id)
+ : context(context), name(name), extension_id(extension_id) {
}
v8::Persistent<v8::Context> context;
std::string name;
+ std::string extension_id;
};
typedef std::map<int, linked_ptr<PendingRequest> > PendingRequestMap;
@@ -473,7 +475,7 @@ class ExtensionImpl : public ChromeV8Extension {
v8::Persistent<v8::Context>::New(v8::Context::GetCurrent());
DCHECK(!v8_context.IsEmpty());
g_pending_requests.Get()[request_id].reset(new PendingRequest(
- v8_context, name));
+ v8_context, name, current_context->extension_id()));
ExtensionHostMsg_Request_Params params;
params.name = name;
@@ -605,7 +607,8 @@ void ExtensionProcessBindings::HandleResponse(
int request_id,
bool success,
const std::string& response,
- const std::string& error) {
+ const std::string& error,
+ std::string* extension_id) {
PendingRequestMap::iterator request =
g_pending_requests.Get().find(request_id);
if (request == g_pending_requests.Get().end()) {
@@ -642,7 +645,21 @@ void ExtensionProcessBindings::HandleResponse(
}
#endif
+ // Save the extension id before erasing the request.
+ *extension_id = request->second->extension_id;
+
request->second->context.Dispose();
request->second->context.Clear();
g_pending_requests.Get().erase(request);
}
+
+// static
+bool ExtensionProcessBindings::HasPendingRequests(
+ const std::string& extension_id) {
+ for (PendingRequestMap::const_iterator it = g_pending_requests.Get().begin();
+ it != g_pending_requests.Get().end(); ++it) {
+ if (it->second->extension_id == extension_id)
+ return true;
+ }
+ return false;
+}
« no previous file with comments | « chrome/renderer/extensions/extension_process_bindings.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698