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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 2049363003: Adds support for headless chrome embedder mojo services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment plus a rename Created 4 years, 6 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
« no previous file with comments | « content/renderer/mojo_context_state.cc ('k') | headless/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 3cb989d5ae28b7f4c3b76487cb4f909bf0237559..4bffcc0ca41c0bd206edb8e7bd35d88ccd201d7e 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -5900,11 +5900,18 @@ void RenderFrameImpl::SendUpdateState() {
void RenderFrameImpl::MaybeEnableMojoBindings() {
int enabled_bindings = RenderProcess::current()->GetEnabledBindings();
- // BINDINGS_POLICY_WEB_UI and BINDINGS_POLICY_MOJO are mutually exclusive.
- // They both provide access to Mojo bindings, but do so in incompatible ways.
- const int kMojoAndWebUiBindings =
- BINDINGS_POLICY_WEB_UI | BINDINGS_POLICY_MOJO;
- DCHECK_NE(enabled_bindings & kMojoAndWebUiBindings, kMojoAndWebUiBindings);
+ // BINDINGS_POLICY_WEB_UI, BINDINGS_POLICY_MOJO and BINDINGS_POLICY_HEADLESS
+ // are mutually exclusive. They provide access to Mojo bindings, but do so in
+ // incompatible ways.
+ const int kAllBindingsTypes =
+ BINDINGS_POLICY_WEB_UI | BINDINGS_POLICY_MOJO | BINDINGS_POLICY_HEADLESS;
+
+ // Make sure that at most one of BINDINGS_POLICY_WEB_UI, BINDINGS_POLICY_MOJO
+ // and BINDINGS_POLICY_HEADLESS have been set.
+ // NOTE x & (x - 1) == 0 is true iff x is zero or a power of two.
Charlie Reis 2016/06/27 21:53:33 Thanks for adding the comment-- it was too clever
+ DCHECK_EQ((enabled_bindings & kAllBindingsTypes) &
+ ((enabled_bindings & kAllBindingsTypes) - 1),
+ 0);
// If an MojoBindingsController already exists for this RenderFrameImpl, avoid
// creating another one. It is not kept as a member, as it deletes itself when
@@ -5914,9 +5921,11 @@ void RenderFrameImpl::MaybeEnableMojoBindings() {
if (IsMainFrame() &&
enabled_bindings & BINDINGS_POLICY_WEB_UI) {
- new MojoBindingsController(this, false /* for_layout_tests */);
+ new MojoBindingsController(this, MojoBindingsType::FOR_WEB_UI);
} else if (enabled_bindings & BINDINGS_POLICY_MOJO) {
- new MojoBindingsController(this, true /* for_layout_tests */);
+ new MojoBindingsController(this, MojoBindingsType::FOR_LAYOUT_TESTS);
+ } else if (enabled_bindings & BINDINGS_POLICY_HEADLESS) {
+ new MojoBindingsController(this, MojoBindingsType::FOR_HEADLESS);
}
}
« no previous file with comments | « content/renderer/mojo_context_state.cc ('k') | headless/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698