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

Unified Diff: content/browser/intents/intent_injector_unittest.cc

Issue 10218009: Allow severing connection between dispatcher and injector (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix compile issue for browser_tests Created 8 years, 8 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: content/browser/intents/intent_injector_unittest.cc
diff --git a/content/browser/intents/intent_injector_unittest.cc b/content/browser/intents/intent_injector_unittest.cc
index 657df55b24ad3bd519a86f6308d1db122adbc9ee..60b75237a9e44d0ae966f10ecfd8bc41625e5084 100644
--- a/content/browser/intents/intent_injector_unittest.cc
+++ b/content/browser/intents/intent_injector_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/bind.h"
+#include "base/memory/weak_ptr.h"
#include "base/utf_string_conversions.h"
#include "content/browser/intents/intent_injector.h"
#include "content/browser/intents/internal_web_intents_dispatcher.h"
@@ -88,3 +89,19 @@ TEST_F(IntentInjectorTest, TestDispatchLimitedToSameOrigin) {
EXPECT_TRUE(NULL == process()->sink().GetFirstMessageMatching(
IntentsMsg_SetWebIntentData::ID));
}
+
+TEST_F(IntentInjectorTest, AbandonDeletes) {
+ IntentInjector* injector = new IntentInjector(web_contents());
+
+ base::WeakPtr<IntentInjector> weak_injector =
+ injector->weak_factory_.GetWeakPtr();
+ EXPECT_FALSE(weak_injector.get() == NULL);
+ weak_injector->Abandon();
+ EXPECT_TRUE(weak_injector.get() == NULL);
+
+ // Sending a message will both auto-delete |dispatcher_| to clean up and
+ // verify that messages don't get sent to the (now deleted) |injector|.
+ dispatcher_->SendReplyMessage(
+ webkit_glue::WEB_INTENT_SERVICE_CONTENTS_CLOSED, string16());
+
+}
« no previous file with comments | « content/browser/intents/intent_injector.cc ('k') | content/browser/intents/internal_web_intents_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698