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

Unified Diff: media/blink/multibuffer_data_source_unittest.cc

Issue 1984083003: Avoid using vtable of destroyed object in MultiBuffer unit test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/multibuffer_data_source_unittest.cc
diff --git a/media/blink/multibuffer_data_source_unittest.cc b/media/blink/multibuffer_data_source_unittest.cc
index f265046163ba688773acbf7e17bc19254084233f..fc4973276955f0a720d6682abd674a51dbfc449b 100644
--- a/media/blink/multibuffer_data_source_unittest.cc
+++ b/media/blink/multibuffer_data_source_unittest.cc
@@ -54,19 +54,17 @@ class TestMultiBufferDataProvider : public ResourceMultiBufferDataProvider {
~TestMultiBufferDataProvider() override {
CHECK_EQ(static_cast<size_t>(1), test_data_providers.erase(this));
}
- void SetLoadingToFalse() {
- // Check that we have not been destroyed first.
- if (test_data_providers.find(this) != test_data_providers.end()) {
- loading_ = false;
- }
- }
void Start() override {
// Create a mock active loader.
// Keep track of active loading state via loadAsynchronously() and cancel().
NiceMock<MockWebURLLoader>* url_loader = new NiceMock<MockWebURLLoader>();
ON_CALL(*url_loader, cancel())
- .WillByDefault(
- Invoke(this, &TestMultiBufferDataProvider::SetLoadingToFalse));
+ .WillByDefault(Invoke([this]() {
+ // Check that we have not been destroyed first.
+ if (test_data_providers.find(this) != test_data_providers.end()) {
+ this->loading_ = false;
+ }
+ }));
loading_ = true;
active_loader_.reset(
new ActiveLoader(std::unique_ptr<WebURLLoader>(url_loader)));
« 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