Commit 405549be authored by Timothy Loh's avatar Timothy Loh Committed by Commit Bot

Remove redundant clearing from ~PermissionRequestManager()

PermissionRequestManager's destructor currently clears its request
vectors, but as it is a WebContentsUserData these should already have
been cleared in WebContentsDestroyed. This patch replaces this with
assertions the vectors are empty.

Change-Id: I71d56e91356435698c9dbcb4fcc347b997d05e6f
Reviewed-on: https://chromium-review.googlesource.com/562845Reviewed-by: default avatarRaymes Khoury <raymes@chromium.org>
Commit-Queue: Timothy Loh <timloh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485176}
parent 51446e5d
...@@ -121,15 +121,9 @@ PermissionRequestManager::PermissionRequestManager( ...@@ -121,15 +121,9 @@ PermissionRequestManager::PermissionRequestManager(
} }
PermissionRequestManager::~PermissionRequestManager() { PermissionRequestManager::~PermissionRequestManager() {
if (view_ != NULL) DCHECK(requests_.empty());
view_->SetDelegate(NULL); DCHECK(duplicate_requests_.empty());
DCHECK(queued_requests_.empty());
for (PermissionRequest* request : requests_)
request->RequestFinished();
for (PermissionRequest* request : queued_requests_)
request->RequestFinished();
for (const auto& entry : duplicate_requests_)
entry.second->RequestFinished();
} }
void PermissionRequestManager::AddRequest(PermissionRequest* request) { void PermissionRequestManager::AddRequest(PermissionRequest* request) {
......
...@@ -51,13 +51,13 @@ class PermissionRequestManagerTest : public ChromeRenderViewHostTestHarness { ...@@ -51,13 +51,13 @@ class PermissionRequestManagerTest : public ChromeRenderViewHostTestHarness {
SetContents(CreateTestWebContents()); SetContents(CreateTestWebContents());
NavigateAndCommit(GURL("http://www.google.com")); NavigateAndCommit(GURL("http://www.google.com"));
manager_.reset(new PermissionRequestManager(web_contents())); PermissionRequestManager::CreateForWebContents(web_contents());
prompt_factory_.reset(new MockPermissionPromptFactory(manager_.get())); manager_ = PermissionRequestManager::FromWebContents(web_contents());
prompt_factory_.reset(new MockPermissionPromptFactory(manager_));
} }
void TearDown() override { void TearDown() override {
prompt_factory_.reset(); prompt_factory_.reset();
manager_.reset();
ChromeRenderViewHostTestHarness::TearDown(); ChromeRenderViewHostTestHarness::TearDown();
} }
...@@ -101,7 +101,7 @@ class PermissionRequestManagerTest : public ChromeRenderViewHostTestHarness { ...@@ -101,7 +101,7 @@ class PermissionRequestManagerTest : public ChromeRenderViewHostTestHarness {
MockPermissionRequest iframe_request_same_domain_; MockPermissionRequest iframe_request_same_domain_;
MockPermissionRequest iframe_request_other_domain_; MockPermissionRequest iframe_request_other_domain_;
MockPermissionRequest iframe_request_mic_other_domain_; MockPermissionRequest iframe_request_mic_other_domain_;
std::unique_ptr<PermissionRequestManager> manager_; PermissionRequestManager* manager_;
std::unique_ptr<MockPermissionPromptFactory> prompt_factory_; std::unique_ptr<MockPermissionPromptFactory> prompt_factory_;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment