| OLD | NEW |
| 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 delegate_(nullptr) {} | 471 delegate_(nullptr) {} |
| 472 | 472 |
| 473 UIThreadExtensionFunction::~UIThreadExtensionFunction() { | 473 UIThreadExtensionFunction::~UIThreadExtensionFunction() { |
| 474 if (dispatcher() && render_frame_host()) | 474 if (dispatcher() && render_frame_host()) |
| 475 dispatcher()->OnExtensionFunctionCompleted(extension()); | 475 dispatcher()->OnExtensionFunctionCompleted(extension()); |
| 476 // The extension function should always respond to avoid leaks in the | 476 // The extension function should always respond to avoid leaks in the |
| 477 // renderer, dangling callbacks, etc. The exception is if the system is | 477 // renderer, dangling callbacks, etc. The exception is if the system is |
| 478 // shutting down. | 478 // shutting down. |
| 479 // TODO(devlin): Duplicate this check in IOThreadExtensionFunction. It's | 479 // TODO(devlin): Duplicate this check in IOThreadExtensionFunction. It's |
| 480 // tricky because checking IsShuttingDown has to be called from the UI thread. | 480 // tricky because checking IsShuttingDown has to be called from the UI thread. |
| 481 extensions::ExtensionsBrowserClient* browser_client = | 481 DCHECK(extensions::ExtensionsBrowserClient::Get()->IsShuttingDown() || |
| 482 extensions::ExtensionsBrowserClient::Get(); | 482 did_respond_ || ignore_all_did_respond_for_testing_do_not_use) |
| 483 DCHECK(!browser_client || browser_client->IsShuttingDown() || did_respond_ || | |
| 484 ignore_all_did_respond_for_testing_do_not_use) | |
| 485 << name_; | 483 << name_; |
| 486 } | 484 } |
| 487 | 485 |
| 488 UIThreadExtensionFunction* | 486 UIThreadExtensionFunction* |
| 489 UIThreadExtensionFunction::AsUIThreadExtensionFunction() { | 487 UIThreadExtensionFunction::AsUIThreadExtensionFunction() { |
| 490 return this; | 488 return this; |
| 491 } | 489 } |
| 492 | 490 |
| 493 bool UIThreadExtensionFunction::PreRunValidation(std::string* error) { | 491 bool UIThreadExtensionFunction::PreRunValidation(std::string* error) { |
| 494 if (!ExtensionFunction::PreRunValidation(error)) | 492 if (!ExtensionFunction::PreRunValidation(error)) |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() { | 649 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() { |
| 652 return RespondNow(RunSync() ? ArgumentList(std::move(results_)) | 650 return RespondNow(RunSync() ? ArgumentList(std::move(results_)) |
| 653 : Error(error_)); | 651 : Error(error_)); |
| 654 } | 652 } |
| 655 | 653 |
| 656 // static | 654 // static |
| 657 bool SyncIOThreadExtensionFunction::ValidationFailure( | 655 bool SyncIOThreadExtensionFunction::ValidationFailure( |
| 658 SyncIOThreadExtensionFunction* function) { | 656 SyncIOThreadExtensionFunction* function) { |
| 659 return false; | 657 return false; |
| 660 } | 658 } |
| OLD | NEW |