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

Unified Diff: blimp/client/public/contents/blimp_contents_observer.cc

Issue 2201433002: Migrate TabControlFeature from 0.5 to 0.6 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address all of tommy's comments 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/public/contents/blimp_contents_observer.cc
diff --git a/blimp/client/public/contents/blimp_contents_observer.cc b/blimp/client/public/contents/blimp_contents_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9706c4224a44cd11f0749efa81be42ad25c2acc8
--- /dev/null
+++ b/blimp/client/public/contents/blimp_contents_observer.cc
@@ -0,0 +1,31 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "blimp/client/public/contents/blimp_contents.h"
+#include "blimp/client/public/contents/blimp_contents_observer.h"
+
+namespace blimp {
+namespace client {
+
+BlimpContentsObserver::BlimpContentsObserver(BlimpContents* blimp_contents)
+ : contents_(blimp_contents) {
+ blimp_contents->AddObserver(this);
+}
+
+BlimpContentsObserver::~BlimpContentsObserver() {
David Trainor- moved to gerrit 2016/08/06 04:32:58 Can we have two unit tests for this? 1. When this
Menglin 2016/08/09 00:31:18 Done.
+ if (contents_)
+ contents_->RemoveObserver(this);
+}
+
+void BlimpContentsObserver::OnContentsDestroyed() {
+ DCHECK(contents_);
+ ClearBlimpContents();
+}
+
+void BlimpContentsObserver::ClearBlimpContents() {
+ contents_ = nullptr;
+}
+
+} // namespace client
+} // namespace blimp

Powered by Google App Engine
This is Rietveld 408576698