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

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

Issue 2166523003: Add ref count to service workers for extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.h" 5 #include "extensions/browser/extension_function.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 } 461 }
462 462
463 void ExtensionFunction::OnRespondingLater(ResponseValue value) { 463 void ExtensionFunction::OnRespondingLater(ResponseValue value) {
464 SendResponse(value->Apply()); 464 SendResponse(value->Apply());
465 } 465 }
466 466
467 UIThreadExtensionFunction::UIThreadExtensionFunction() 467 UIThreadExtensionFunction::UIThreadExtensionFunction()
468 : context_(nullptr), 468 : context_(nullptr),
469 render_frame_host_(nullptr), 469 render_frame_host_(nullptr),
470 is_from_service_worker_(false), 470 is_from_service_worker_(false),
471 embedded_worker_id_(-1),
471 delegate_(nullptr) {} 472 delegate_(nullptr) {}
472 473
473 UIThreadExtensionFunction::~UIThreadExtensionFunction() { 474 UIThreadExtensionFunction::~UIThreadExtensionFunction() {
474 if (dispatcher() && render_frame_host()) 475 if (dispatcher() && (render_frame_host() || is_from_service_worker_)) {
475 dispatcher()->OnExtensionFunctionCompleted(extension()); 476 dispatcher()->OnExtensionFunctionCompleted(extension(),
477 embedded_worker_id_);
478 }
479
476 // The extension function should always respond to avoid leaks in the 480 // The extension function should always respond to avoid leaks in the
477 // renderer, dangling callbacks, etc. The exception is if the system is 481 // renderer, dangling callbacks, etc. The exception is if the system is
478 // shutting down. 482 // shutting down.
479 // TODO(devlin): Duplicate this check in IOThreadExtensionFunction. It's 483 // TODO(devlin): Duplicate this check in IOThreadExtensionFunction. It's
480 // tricky because checking IsShuttingDown has to be called from the UI thread. 484 // tricky because checking IsShuttingDown has to be called from the UI thread.
481 DCHECK(extensions::ExtensionsBrowserClient::Get()->IsShuttingDown() || 485 DCHECK(extensions::ExtensionsBrowserClient::Get()->IsShuttingDown() ||
482 did_respond_ || ignore_all_did_respond_for_testing_do_not_use) 486 did_respond_ || ignore_all_did_respond_for_testing_do_not_use)
483 << name_; 487 << name_;
484 } 488 }
485 489
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() { 653 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() {
650 return RespondNow(RunSync() ? ArgumentList(std::move(results_)) 654 return RespondNow(RunSync() ? ArgumentList(std::move(results_))
651 : Error(error_)); 655 : Error(error_));
652 } 656 }
653 657
654 // static 658 // static
655 bool SyncIOThreadExtensionFunction::ValidationFailure( 659 bool SyncIOThreadExtensionFunction::ValidationFailure(
656 SyncIOThreadExtensionFunction* function) { 660 SyncIOThreadExtensionFunction* function) {
657 return false; 661 return false;
658 } 662 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698