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

Side by Side Diff: extensions/browser/extension_function_dispatcher.cc

Issue 798103002: Possible fix for ExtensionFunctionDispatcher::DispatchWithCallbackInternal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/extension_function_dispatcher.h" 5 #include "extensions/browser/extension_function_dispatcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 if (!CheckPermissions(function.get(), params, callback)) 371 if (!CheckPermissions(function.get(), params, callback))
372 return; 372 return;
373 373
374 if (!extension) { 374 if (!extension) {
375 // Skip all of the UMA, quota, event page, activity logging stuff if there 375 // Skip all of the UMA, quota, event page, activity logging stuff if there
376 // isn't an extension, e.g. if the function call was from WebUI. 376 // isn't an extension, e.g. if the function call was from WebUI.
377 function->Run()->Execute(); 377 function->Run()->Execute();
378 return; 378 return;
379 } 379 }
380 380
381 // Fetch the ProcessManager before |this| is possibly invalidated.
382 ProcessManager* process_manager = ProcessManager::Get(browser_context_);
383
381 ExtensionSystem* extension_system = ExtensionSystem::Get(browser_context_); 384 ExtensionSystem* extension_system = ExtensionSystem::Get(browser_context_);
382 QuotaService* quota = extension_system->quota_service(); 385 QuotaService* quota = extension_system->quota_service();
383 std::string violation_error = quota->Assess(extension->id(), 386 std::string violation_error = quota->Assess(extension->id(),
384 function.get(), 387 function.get(),
385 &params.arguments, 388 &params.arguments,
386 base::TimeTicks::Now()); 389 base::TimeTicks::Now());
387 390
388 if (violation_error.empty()) { 391 if (violation_error.empty()) {
389 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy()); 392 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy());
390 393
(...skipping 12 matching lines...) Expand all
403 // if function->Run() ended up closing the tab that owns us. 406 // if function->Run() ended up closing the tab that owns us.
404 407
405 // Check if extension was uninstalled by management.uninstall. 408 // Check if extension was uninstalled by management.uninstall.
406 if (!registry->enabled_extensions().GetByID(params.extension_id)) 409 if (!registry->enabled_extensions().GetByID(params.extension_id))
407 return; 410 return;
408 411
409 // We only adjust the keepalive count for UIThreadExtensionFunction for 412 // We only adjust the keepalive count for UIThreadExtensionFunction for
410 // now, largely for simplicity's sake. This is OK because currently, only 413 // now, largely for simplicity's sake. This is OK because currently, only
411 // the webRequest API uses IOThreadExtensionFunction, and that API is not 414 // the webRequest API uses IOThreadExtensionFunction, and that API is not
412 // compatible with lazy background pages. 415 // compatible with lazy background pages.
413 ProcessManager::Get(browser_context_)->IncrementLazyKeepaliveCount(extension); 416 process_manager->IncrementLazyKeepaliveCount(extension);
414 } 417 }
415 418
416 void ExtensionFunctionDispatcher::OnExtensionFunctionCompleted( 419 void ExtensionFunctionDispatcher::OnExtensionFunctionCompleted(
417 const Extension* extension) { 420 const Extension* extension) {
418 if (extension) { 421 if (extension) {
419 ProcessManager::Get(browser_context_) 422 ProcessManager::Get(browser_context_)
420 ->DecrementLazyKeepaliveCount(extension); 423 ->DecrementLazyKeepaliveCount(extension);
421 } 424 }
422 } 425 }
423 426
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 471
469 // static 472 // static
470 void ExtensionFunctionDispatcher::SendAccessDenied( 473 void ExtensionFunctionDispatcher::SendAccessDenied(
471 const ExtensionFunction::ResponseCallback& callback) { 474 const ExtensionFunction::ResponseCallback& callback) {
472 base::ListValue empty_list; 475 base::ListValue empty_list;
473 callback.Run(ExtensionFunction::FAILED, empty_list, 476 callback.Run(ExtensionFunction::FAILED, empty_list,
474 "Access to extension API denied."); 477 "Access to extension API denied.");
475 } 478 }
476 479
477 } // namespace extensions 480 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698