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

Unified Diff: blimp/client/core/contents/blimp_contents_manager.cc

Issue 2299453002: Restrict number of BlimpContents to [0, 1] (Closed)
Patch Set: Created 4 years, 4 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
Index: blimp/client/core/contents/blimp_contents_manager.cc
diff --git a/blimp/client/core/contents/blimp_contents_manager.cc b/blimp/client/core/contents/blimp_contents_manager.cc
index e93a018e574ce3eb0f6430315bade477052fe9d1..80023c697983596ad2e7c2a81064d7a87f9b83de 100644
--- a/blimp/client/core/contents/blimp_contents_manager.cc
+++ b/blimp/client/core/contents/blimp_contents_manager.cc
@@ -56,6 +56,9 @@ BlimpContentsManager::BlimpContentsManager(
BlimpContentsManager::~BlimpContentsManager() {}
std::unique_ptr<BlimpContentsImpl> BlimpContentsManager::CreateBlimpContents() {
+ if (tab_exists_) return nullptr;
+ tab_exists_ = true;
+
int id = CreateBlimpContentsId();
std::unique_ptr<BlimpContentsImpl> new_contents =
@@ -100,6 +103,9 @@ void BlimpContentsManager::EraseObserverFromMap(int id) {
}
void BlimpContentsManager::OnContentsDestroyed(BlimpContents* contents) {
+ DCHECK(tab_exists_);
+ tab_exists_ = false;
+
int id = static_cast<BlimpContentsImpl*>(contents)->id();
// Notify the engine that we've destroyed the BlimpContents.

Powered by Google App Engine
This is Rietveld 408576698