Chromium Code Reviews| Index: content/public/test/content_browser_sanity_checker.cc |
| diff --git a/content/public/test/content_browser_sanity_checker.cc b/content/public/test/content_browser_sanity_checker.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ff5cc1ecf43cf980a99bfc6189c535a590623283 |
| --- /dev/null |
| +++ b/content/public/test/content_browser_sanity_checker.cc |
| @@ -0,0 +1,38 @@ |
| +// Copyright 2014 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 "content/public/test/content_browser_sanity_checker.h" |
| + |
| +#include "base/bind.h" |
| +#include "content/browser/web_contents/web_contents_impl.h" |
| +#include "content/public/test/web_contents_observer_sanity_checker.h" |
| + |
| +namespace content { |
| + |
| +namespace { |
| +bool g_consistency_checks_already_enabled = false; |
| +} |
| + |
| +ContentBrowserSanityChecker::ContentBrowserSanityChecker() { |
| + CHECK(!g_consistency_checks_already_enabled) |
| + << "There's no point in enabling this twice."; |
|
Avi (use Gerrit)
2014/12/22 22:53:50
Don't use "this" here; make the error message self
ncarter (slow)
2014/12/23 00:17:03
Done.
|
| + g_consistency_checks_already_enabled = true; |
| + |
| + creation_hook_ = |
| + base::Bind(&ContentBrowserSanityChecker::OnWebContentsCreated, |
| + base::Unretained(this)); |
| + WebContentsImpl::FriendZone::AddCreatedCallbackForTesting(creation_hook_); |
| +} |
| + |
| +ContentBrowserSanityChecker::~ContentBrowserSanityChecker() { |
| + WebContentsImpl::FriendZone::RemoveCreatedCallbackForTesting(creation_hook_); |
| + g_consistency_checks_already_enabled = false; |
| +} |
| + |
| +void ContentBrowserSanityChecker::OnWebContentsCreated( |
| + WebContents* web_contents) { |
| + WebContentsObserverSanityChecker::Enable(web_contents); |
| +} |
| + |
| +} // namespace content |