Handle Mozilla license blocks in the GN header checker.

The include iterator doesn't handle real C preprocessor. Mozilla license blocks
use C-style comments with *'s along the left, and are long enough that the
header checker gives up.

This patch doesn't fix the general comment issue, different types of comments
can still confuse us, but Mozilla license blocks in particular are now handled.

BUG=543850

Review URL: https://codereview.chromium.org/1411573002

Cr-Original-Commit-Position: refs/heads/master@{#354454}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: a2d721a90e955ee4fad4584c150e4aaca42e94d7
diff --git a/tools/gn/c_include_iterator.cc b/tools/gn/c_include_iterator.cc
index 9e719c7..120295e 100644
--- a/tools/gn/c_include_iterator.cc
+++ b/tools/gn/c_include_iterator.cc
@@ -48,6 +48,8 @@
 bool ShouldCountTowardNonIncludeLines(const base::StringPiece& line) {
   if (StartsWith(line, "//"))
     return false;  // Don't count comments.
+  if (StartsWith(line, "/*") || StartsWith(line, " *"))
+    return false;  // C-style comment blocks with stars along the left side.
   if (StartsWith(line, "#"))
     return false;  // Don't count preprocessor.
   if (base::ContainsOnlyChars(line, base::kWhitespaceASCII))
diff --git a/tools/gn/c_include_iterator_unittest.cc b/tools/gn/c_include_iterator_unittest.cc
index 11fa991..1add29b 100644
--- a/tools/gn/c_include_iterator_unittest.cc
+++ b/tools/gn/c_include_iterator_unittest.cc
@@ -132,3 +132,26 @@
   }
   EXPECT_FALSE(iter.GetNextIncludeString(&contents, &range));
 }
+
+// Tests that comments of the form
+//    /*
+//     *
+//     */
+// are not counted toward the non-include line count.
+TEST(CIncludeIterator, CStyleComments) {
+  std::string buffer("/*");
+  for (size_t i = 0; i < 1000; i++)
+    buffer.append(" *\n");
+  buffer.append(" */\n\n");
+  buffer.append("#include \"foo/bar.h\"\n");
+
+  InputFile file(SourceFile("//foo.cc"));
+  file.SetContents(buffer);
+
+  base::StringPiece contents;
+  LocationRange range;
+
+  CIncludeIterator iter(&file);
+  EXPECT_TRUE(iter.GetNextIncludeString(&contents, &range));
+  EXPECT_EQ("foo/bar.h", contents);
+}