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

Side by Side Diff: chrome/renderer/extensions/extension_dispatcher.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: Only track in-flight events when lazy 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
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 #include "chrome/renderer/extensions/extension_dispatcher.h" 5 #include "chrome/renderer/extensions/extension_dispatcher.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/common/child_process_logging.h" 8 #include "chrome/common/child_process_logging.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 v8_context_set_.DispatchChromeHiddenMethod( 147 v8_context_set_.DispatchChromeHiddenMethod(
148 extension_id, function_name, args, NULL, event_url); 148 extension_id, function_name, args, NULL, event_url);
149 149
150 // Reset the idle handler each time there's any activity like event or message 150 // Reset the idle handler each time there's any activity like event or message
151 // dispatch, for which Invoke is the chokepoint. 151 // dispatch, for which Invoke is the chokepoint.
152 if (is_extension_process_) { 152 if (is_extension_process_) {
153 RenderThread::Get()->ScheduleIdleHandler( 153 RenderThread::Get()->ScheduleIdleHandler(
154 kInitialExtensionIdleHandlerDelayS); 154 kInitialExtensionIdleHandlerDelayS);
155 } 155 }
156 156
157 // Tell the browser process that we're idle. 157 // Tell the browser process that the event is dispatched and we're idle.
158 if (CommandLine::ForCurrentProcess()->HasSwitch( 158 if (CommandLine::ForCurrentProcess()->HasSwitch(
159 switches::kEnableLazyBackgroundPages) && 159 switches::kEnableLazyBackgroundPages) &&
160 function_name == "Event.dispatchJSON") // may always be true 160 function_name == "Event.dispatchJSON") { // may always be true
161 RenderThread::Get()->Send(new ExtensionHostMsg_EventDispatch(extension_id));
162 OnExtensionIdle(extension_id);
163 }
164 }
165
166 void ExtensionDispatcher::OnExtensionIdle(const std::string& extension_id) {
Aaron Boodman 2011/10/31 17:46:08 How about "CheckIdleStatus".
Tessa MacDuff 2011/10/31 19:01:29 Done.
167 if (!ExtensionProcessBindings::HasPendingRequests(extension_id))
161 RenderThread::Get()->Send(new ExtensionHostMsg_ExtensionIdle(extension_id)); 168 RenderThread::Get()->Send(new ExtensionHostMsg_ExtensionIdle(extension_id));
162 } 169 }
163 170
164 void ExtensionDispatcher::OnDeliverMessage(int target_port_id, 171 void ExtensionDispatcher::OnDeliverMessage(int target_port_id,
165 const std::string& message) { 172 const std::string& message) {
166 RendererExtensionBindings::DeliverMessage( 173 RendererExtensionBindings::DeliverMessage(
167 v8_context_set_.GetAll(), 174 v8_context_set_.GetAll(),
168 target_port_id, 175 target_port_id,
169 message, 176 message,
170 NULL); // All render views. 177 NULL); // All render views.
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 406
400 RenderThread::Get()->RegisterExtension(extension); 407 RenderThread::Get()->RegisterExtension(extension);
401 } 408 }
402 409
403 void ExtensionDispatcher::OnUsingWebRequestAPI( 410 void ExtensionDispatcher::OnUsingWebRequestAPI(
404 bool adblock, bool adblock_plus, bool other) { 411 bool adblock, bool adblock_plus, bool other) {
405 webrequest_adblock_ = adblock; 412 webrequest_adblock_ = adblock;
406 webrequest_adblock_plus_ = adblock_plus; 413 webrequest_adblock_plus_ = adblock_plus;
407 webrequest_other_ = other; 414 webrequest_other_ = other;
408 } 415 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698