update_engine: Fix a memory access violation

Somewhere down in HttpFetcher there is a pointer to
ChromeBrowserProxyResolver. But the actual object gets deleted before
ActionProcessor is deleted. But ActionProcessor's dtor makes calls that
sometimes eventually gets into the instance of ChromeBrowserproxyresolver and we
get a memory violation.

For now just declare ChromeBrowserProxyResolver before ActionProcessor so it
still exists when the ActionProcessor uses it. Later use shared_ptr to properly
handle it.

BUG=chromium:915922
TEST=cros flash
TEST=Instrumented the dtors and manually stopped the update_engine process to
see the order of dtors are correct.

Change-Id: Ie9fa654103605f04c82521c29614dbcd4fb083e8
Reviewed-on: https://chromium-review.googlesource.com/1388105
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Sen Jiang <senj@chromium.org>
diff --git a/update_attempter.h b/update_attempter.h
index 9e1f2ac..12fe3f8 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -432,6 +432,12 @@
   // set back in the middle of an update.
   base::TimeTicks last_notify_time_;
 
+  // Our two proxy resolvers
+  DirectProxyResolver direct_proxy_resolver_;
+#if USE_CHROME_NETWORK_PROXY
+  ChromeBrowserProxyResolver chrome_proxy_resolver_;
+#endif  // USE_CHROME_NETWORK_PROXY
+
   std::unique_ptr<ActionProcessor> processor_;
 
   // External state of the system outside the update_engine process
@@ -491,12 +497,6 @@
   // If true, this update cycle we are obeying proxies
   bool obeying_proxies_ = true;
 
-  // Our two proxy resolvers
-  DirectProxyResolver direct_proxy_resolver_;
-#if USE_CHROME_NETWORK_PROXY
-  ChromeBrowserProxyResolver chrome_proxy_resolver_;
-#endif  // USE_CHROME_NETWORK_PROXY
-
   // Used for fetching information about the device policy.
   std::unique_ptr<policy::PolicyProvider> policy_provider_;
 
diff --git a/update_attempter_android.h b/update_attempter_android.h
index cad89dc..99aa14e 100644
--- a/update_attempter_android.h
+++ b/update_attempter_android.h
@@ -172,6 +172,9 @@
   // set back in the middle of an update.
   base::TimeTicks last_notify_time_;
 
+  // Only direct proxy supported.
+  DirectProxyResolver proxy_resolver_;
+
   // The processor for running Actions.
   std::unique_ptr<ActionProcessor> processor_;
 
@@ -190,9 +193,6 @@
   // The offset in the payload file where the CrAU part starts.
   int64_t base_offset_{0};
 
-  // Only direct proxy supported.
-  DirectProxyResolver proxy_resolver_;
-
   // Helper class to select the network to use during the update.
   std::unique_ptr<NetworkSelectorInterface> network_selector_;