Include the implemented header first in all projects.

The Google C++ style guide dictates that foo.cc and foo_unittest.cc
should include foo.h in the first place, so missing headers in foo.h
are detected with a compile error of the module implementing them and
not when another module uses them.

This CL sweeps across all the .cc file in platform2 enforcing this.

BUG=None
TEST=cbuildbot amd64-generic

Change-Id: I41835835caba13f54c3c844ecf552eb0e47efa9d
Reviewed-on: https://chromium-review.googlesource.com/228894
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/action_pipe_unittest.cc b/action_pipe_unittest.cc
index 0f777fb..3cdd03d 100644
--- a/action_pipe_unittest.cc
+++ b/action_pipe_unittest.cc
@@ -2,10 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/action_pipe.h"
+
 #include <string>
 #include <gtest/gtest.h>
 #include "update_engine/action.h"
-#include "update_engine/action_pipe.h"
 
 using std::string;
 
diff --git a/action_processor_unittest.cc b/action_processor_unittest.cc
index cde1eec..64e847d 100644
--- a/action_processor_unittest.cc
+++ b/action_processor_unittest.cc
@@ -2,10 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/action_processor.h"
+
 #include <string>
 #include <gtest/gtest.h>
 #include "update_engine/action.h"
-#include "update_engine/action_processor.h"
 
 using std::string;
 
diff --git a/action_unittest.cc b/action_unittest.cc
index 4ab5166..a5f7b11 100644
--- a/action_unittest.cc
+++ b/action_unittest.cc
@@ -2,9 +2,10 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/action.h"
+
 #include <string>
 #include <gtest/gtest.h>
-#include "update_engine/action.h"
 #include "update_engine/action_processor.h"
 
 using std::string;
diff --git a/bzip.cc b/bzip.cc
index 808ae89..2b225c0 100644
--- a/bzip.cc
+++ b/bzip.cc
@@ -3,6 +3,7 @@
 // found in the LICENSE file.
 
 #include "update_engine/bzip.h"
+
 #include <stdlib.h>
 #include <algorithm>
 #include <bzlib.h>
diff --git a/bzip_extent_writer_unittest.cc b/bzip_extent_writer_unittest.cc
index 96121d4..0aa8709 100644
--- a/bzip_extent_writer_unittest.cc
+++ b/bzip_extent_writer_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/bzip_extent_writer.h"
+
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
@@ -9,7 +11,6 @@
 #include <string>
 #include <vector>
 #include <gtest/gtest.h>
-#include "update_engine/bzip_extent_writer.h"
 #include "update_engine/test_utils.h"
 #include "update_engine/utils.h"
 
diff --git a/chrome_browser_proxy_resolver_unittest.cc b/chrome_browser_proxy_resolver_unittest.cc
index 3974f3b..d3cf99e 100644
--- a/chrome_browser_proxy_resolver_unittest.cc
+++ b/chrome_browser_proxy_resolver_unittest.cc
@@ -2,12 +2,13 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/chrome_browser_proxy_resolver.h"
+
 #include <deque>
 #include <string>
 
 #include <gtest/gtest.h>
 
-#include "update_engine/chrome_browser_proxy_resolver.h"
 #include "update_engine/mock_dbus_wrapper.h"
 
 using ::testing::Return;
diff --git a/download_action.cc b/download_action.cc
index f37828b..35b1174 100644
--- a/download_action.cc
+++ b/download_action.cc
@@ -3,6 +3,7 @@
 // found in the LICENSE file.
 
 #include "update_engine/download_action.h"
+
 #include <errno.h>
 #include <algorithm>
 #include <string>
diff --git a/extent_ranges_unittest.cc b/extent_ranges_unittest.cc
index 11b17ed..b4de3bc 100644
--- a/extent_ranges_unittest.cc
+++ b/extent_ranges_unittest.cc
@@ -2,11 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/extent_ranges.h"
+
 #include <vector>
 
 #include <gtest/gtest.h>
 
-#include "update_engine/extent_ranges.h"
 #include "update_engine/payload_constants.h"
 #include "update_engine/test_utils.h"
 
diff --git a/file_writer.cc b/file_writer.cc
index ad29844..8f8e989 100644
--- a/file_writer.cc
+++ b/file_writer.cc
@@ -3,6 +3,7 @@
 // found in the LICENSE file.
 
 #include "update_engine/file_writer.h"
+
 #include <errno.h>
 
 namespace chromeos_update_engine {
diff --git a/filesystem_copier_action_unittest.cc b/filesystem_copier_action_unittest.cc
index c551adf..5c40fb3 100644
--- a/filesystem_copier_action_unittest.cc
+++ b/filesystem_copier_action_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/filesystem_copier_action.h"
+
 #include <fcntl.h>
 
 #include <set>
@@ -16,7 +18,6 @@
 #include <gtest/gtest.h>
 
 #include "update_engine/fake_system_state.h"
-#include "update_engine/filesystem_copier_action.h"
 #include "update_engine/mock_hardware.h"
 #include "update_engine/omaha_hash_calculator.h"
 #include "update_engine/test_utils.h"
diff --git a/multi_range_http_fetcher.cc b/multi_range_http_fetcher.cc
index 19263de..63b85c9 100644
--- a/multi_range_http_fetcher.cc
+++ b/multi_range_http_fetcher.cc
@@ -2,12 +2,13 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/multi_range_http_fetcher.h"
+
 #include <base/strings/stringprintf.h>
 
 #include <algorithm>
 #include <string>
 
-#include "update_engine/multi_range_http_fetcher.h"
 #include "update_engine/utils.h"
 
 namespace chromeos_update_engine {
diff --git a/omaha_hash_calculator_unittest.cc b/omaha_hash_calculator_unittest.cc
index 762a528..08e8698 100644
--- a/omaha_hash_calculator_unittest.cc
+++ b/omaha_hash_calculator_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/omaha_hash_calculator.h"
+
 #include <math.h>
 #include <unistd.h>
 
@@ -12,7 +14,6 @@
 #include <gtest/gtest.h>
 
 #include "update_engine/libcurl_http_fetcher.h"
-#include "update_engine/omaha_hash_calculator.h"
 #include "update_engine/utils.h"
 
 using std::string;
diff --git a/omaha_response_handler_action_unittest.cc b/omaha_response_handler_action_unittest.cc
index 418383a..fb99ddb 100644
--- a/omaha_response_handler_action_unittest.cc
+++ b/omaha_response_handler_action_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/omaha_response_handler_action.h"
+
 #include <string>
 
 #include <gtest/gtest.h>
@@ -9,7 +11,6 @@
 #include "update_engine/constants.h"
 #include "update_engine/fake_system_state.h"
 #include "update_engine/mock_payload_state.h"
-#include "update_engine/omaha_response_handler_action.h"
 #include "update_engine/test_utils.h"
 #include "update_engine/utils.h"
 
diff --git a/payload_generator/full_update_generator_unittest.cc b/payload_generator/full_update_generator_unittest.cc
index 559a110..95a40ae 100644
--- a/payload_generator/full_update_generator_unittest.cc
+++ b/payload_generator/full_update_generator_unittest.cc
@@ -2,12 +2,13 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/payload_generator/full_update_generator.h"
+
 #include <string>
 #include <vector>
 
 #include <gtest/gtest.h>
 
-#include "update_engine/payload_generator/full_update_generator.h"
 #include "update_engine/test_utils.h"
 
 using chromeos_update_engine::test_utils::FillWithData;
diff --git a/payload_generator/graph_utils_unittest.cc b/payload_generator/graph_utils_unittest.cc
index 0aed78d..c96927f 100644
--- a/payload_generator/graph_utils_unittest.cc
+++ b/payload_generator/graph_utils_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/payload_generator/graph_utils.h"
+
 #include <utility>
 #include <vector>
 
@@ -9,7 +11,6 @@
 
 #include "update_engine/extent_ranges.h"
 #include "update_engine/payload_constants.h"
-#include "update_engine/payload_generator/graph_utils.h"
 
 using std::make_pair;
 using std::vector;
diff --git a/payload_generator/metadata.cc b/payload_generator/metadata.cc
index 0b4e428..4e0265a 100644
--- a/payload_generator/metadata.cc
+++ b/payload_generator/metadata.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/payload_generator/metadata.h"
+
 #include <algorithm>
 #include <string>
 #include <vector>
@@ -17,7 +19,6 @@
 #include "update_engine/payload_generator/delta_diff_generator.h"
 #include "update_engine/payload_generator/ext2_utils.h"
 #include "update_engine/payload_generator/graph_utils.h"
-#include "update_engine/payload_generator/metadata.h"
 #include "update_engine/utils.h"
 
 using base::StringPrintf;
diff --git a/payload_generator/metadata_unittest.cc b/payload_generator/metadata_unittest.cc
index 2ffb338..6bc56b7 100644
--- a/payload_generator/metadata_unittest.cc
+++ b/payload_generator/metadata_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/payload_generator/metadata.h"
+
 #include <ext2fs/ext2fs.h>
 #include <fcntl.h>
 #include <sys/stat.h>
@@ -16,7 +18,6 @@
 
 #include "update_engine/payload_generator/delta_diff_generator.h"
 #include "update_engine/payload_generator/graph_types.h"
-#include "update_engine/payload_generator/metadata.h"
 #include "update_engine/test_utils.h"
 #include "update_engine/utils.h"
 
diff --git a/payload_generator/topological_sort_unittest.cc b/payload_generator/topological_sort_unittest.cc
index c1d19b7..e5e7477 100644
--- a/payload_generator/topological_sort_unittest.cc
+++ b/payload_generator/topological_sort_unittest.cc
@@ -2,13 +2,14 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/payload_generator/topological_sort.h"
+
 #include <utility>
 #include <vector>
 
 #include <gtest/gtest.h>
 
 #include "update_engine/payload_generator/graph_types.h"
-#include "update_engine/payload_generator/topological_sort.h"
 
 using std::make_pair;
 using std::vector;
diff --git a/prefs_unittest.cc b/prefs_unittest.cc
index 0c81b92..18633e1 100644
--- a/prefs_unittest.cc
+++ b/prefs_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/prefs.h"
+
 #include <inttypes.h>
 
 #include <string>
@@ -12,8 +14,6 @@
 #include <base/strings/stringprintf.h>
 #include <gtest/gtest.h>
 
-#include "update_engine/prefs.h"
-
 using std::string;
 
 namespace chromeos_update_engine {
diff --git a/subprocess_unittest.cc b/subprocess_unittest.cc
index 7fafd9e..4e7ebf6 100644
--- a/subprocess_unittest.cc
+++ b/subprocess_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/subprocess.h"
+
 #include <fcntl.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
@@ -20,7 +22,6 @@
 #include <glib.h>
 #include <gtest/gtest.h>
 
-#include "update_engine/subprocess.h"
 #include "update_engine/test_utils.h"
 #include "update_engine/utils.h"
 
diff --git a/terminator_unittest.cc b/terminator_unittest.cc
index 0096c0c..5e6b2e0 100644
--- a/terminator_unittest.cc
+++ b/terminator_unittest.cc
@@ -2,11 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/terminator.h"
+
 #include <gtest/gtest.h>
 #include <gtest/gtest-spi.h>
 
-#include "update_engine/terminator.h"
-
 using testing::ExitedWithCode;
 
 namespace chromeos_update_engine {
diff --git a/update_manager/boxed_value.cc b/update_manager/boxed_value.cc
index 2307f8d..0acc8cd 100644
--- a/update_manager/boxed_value.cc
+++ b/update_manager/boxed_value.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/update_manager/boxed_value.h"
+
 #include <stdint.h>
 
 #include <set>
@@ -10,7 +12,6 @@
 #include <base/strings/string_number_conversions.h>
 #include <base/time/time.h>
 
-#include "update_engine/update_manager/boxed_value.h"
 #include "update_engine/update_manager/shill_provider.h"
 #include "update_engine/update_manager/updater_provider.h"
 #include "update_engine/utils.h"
diff --git a/update_manager/boxed_value_unittest.cc b/update_manager/boxed_value_unittest.cc
index 77b44c2..62f4bfe 100644
--- a/update_manager/boxed_value_unittest.cc
+++ b/update_manager/boxed_value_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/update_manager/boxed_value.h"
+
 #include <gtest/gtest.h>
 #include <list>
 #include <map>
@@ -11,7 +13,6 @@
 #include <base/strings/stringprintf.h>
 #include <base/time/time.h>
 
-#include "update_engine/update_manager/boxed_value.h"
 #include "update_engine/update_manager/shill_provider.h"
 #include "update_engine/update_manager/umtest_utils.h"
 #include "update_engine/update_manager/updater_provider.h"
diff --git a/update_manager/evaluation_context_unittest.cc b/update_manager/evaluation_context_unittest.cc
index f38b641..c5cc883 100644
--- a/update_manager/evaluation_context_unittest.cc
+++ b/update_manager/evaluation_context_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/update_manager/evaluation_context.h"
+
 #include <memory>
 #include <string>
 
@@ -10,7 +12,6 @@
 
 #include "update_engine/fake_clock.h"
 #include "update_engine/test_utils.h"
-#include "update_engine/update_manager/evaluation_context.h"
 #include "update_engine/update_manager/fake_variable.h"
 #include "update_engine/update_manager/generic_variables.h"
 #include "update_engine/update_manager/mock_variable.h"
diff --git a/update_manager/real_random_provider.cc b/update_manager/real_random_provider.cc
index ea10de6..47cb31d 100644
--- a/update_manager/real_random_provider.cc
+++ b/update_manager/real_random_provider.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/update_manager/real_random_provider.h"
+
 #include <stdio.h>
 #include <unistd.h>
 
@@ -11,7 +13,6 @@
 #include <base/files/scoped_file.h>
 #include <base/strings/stringprintf.h>
 
-#include "update_engine/update_manager/real_random_provider.h"
 #include "update_engine/update_manager/variable.h"
 
 using std::string;
diff --git a/update_manager/real_random_provider_unittest.cc b/update_manager/real_random_provider_unittest.cc
index d7dfeb2..0deba4c 100644
--- a/update_manager/real_random_provider_unittest.cc
+++ b/update_manager/real_random_provider_unittest.cc
@@ -2,11 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/update_manager/real_random_provider.h"
+
 #include <gtest/gtest.h>
 
 #include <memory>
 
-#include "update_engine/update_manager/real_random_provider.h"
 #include "update_engine/update_manager/umtest_utils.h"
 
 using std::unique_ptr;
diff --git a/update_manager/real_shill_provider_unittest.cc b/update_manager/real_shill_provider_unittest.cc
index b384e67..641a5c3 100644
--- a/update_manager/real_shill_provider_unittest.cc
+++ b/update_manager/real_shill_provider_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/update_manager/real_shill_provider.h"
+
 #include <memory>
 #include <utility>
 
@@ -13,7 +15,6 @@
 #include "update_engine/fake_clock.h"
 #include "update_engine/mock_dbus_wrapper.h"
 #include "update_engine/test_utils.h"
-#include "update_engine/update_manager/real_shill_provider.h"
 #include "update_engine/update_manager/umtest_utils.h"
 
 using base::Time;
diff --git a/update_manager/real_time_provider_unittest.cc b/update_manager/real_time_provider_unittest.cc
index 3532ff3..7e27a4e 100644
--- a/update_manager/real_time_provider_unittest.cc
+++ b/update_manager/real_time_provider_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/update_manager/real_time_provider.h"
+
 #include <memory>
 
 #include <base/logging.h>
@@ -9,7 +11,6 @@
 #include <gtest/gtest.h>
 
 #include "update_engine/fake_clock.h"
-#include "update_engine/update_manager/real_time_provider.h"
 #include "update_engine/update_manager/umtest_utils.h"
 
 using base::Time;
diff --git a/update_manager/umtest_utils.cc b/update_manager/umtest_utils.cc
index 41dc0a6..be6a86f 100644
--- a/update_manager/umtest_utils.cc
+++ b/update_manager/umtest_utils.cc
@@ -2,10 +2,10 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <base/time/time.h>
-
 #include "update_engine/update_manager/umtest_utils.h"
 
+#include <base/time/time.h>
+
 namespace chromeos_update_manager {
 
 const unsigned UmTestUtils::kDefaultTimeoutInSeconds = 1;
diff --git a/update_manager/update_manager_unittest.cc b/update_manager/update_manager_unittest.cc
index c0ce092..1d79c5c 100644
--- a/update_manager/update_manager_unittest.cc
+++ b/update_manager/update_manager_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/update_manager/update_manager.h"
+
 #include <unistd.h>
 
 #include <algorithm>
@@ -22,7 +24,6 @@
 #include "update_engine/update_manager/fake_state.h"
 #include "update_engine/update_manager/mock_policy.h"
 #include "update_engine/update_manager/umtest_utils.h"
-#include "update_engine/update_manager/update_manager.h"
 
 using base::Bind;
 using base::Callback;