Add stream printer for WebSandboxFlags

This allows debug messages to print sandbox flags in a convenient binary
format, rather than outputting them as decimal numbers or 4-byte arrays.

This means that you can easily add debug statements for sandboxing code like:

DLOG(INFO) << "The sandbox flags here look like " << sandbox_flags_;

rather than having to cast:

DLOG(INFO) << "The sandbox flags here look like " <<
    std::bitset<32>(static_cast<int>(sandbox_flags_));

It also changes the test output from EXPECT_EQ failures from looking like:

../../content/browser/some_browsertest.cc:12345: Failure
      Expected: blink::WebSandboxFlags::kAll & ~blink::WebSandboxFlags::kScripts & ~blink::WebSandboxFlags::kAutomaticFeatures
      Which is: 4-byte object <6F-FF FF-FF>
To be equal to: root->child_at(1)->effective_frame_policy().sandbox_flags
      Which is: 4-byte object <FF-FA FF-FF>

to the more reasonable:

../../content/browser/some_browsertest.cc:12345: Failure
      Expected: blink::WebSandboxFlags::kAll & ~blink::WebSandboxFlags::kScripts & ~blink::WebSandboxFlags::kAutomaticFeatures
      Which is: 11111111111111111111111101101111
To be equal to: root->child_at(1)->effective_frame_policy().sandbox_flags
      Which is: 11111111111111111111101011111111

in which single bit errors can easily be spotted.

Change-Id: Ibc9020d67654c555e1c70dcb99829e2eb29d0b3c
Reviewed-on: https://chromium-review.googlesource.com/772320
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Commit-Queue: Ian Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574151}
1 file changed