Move actual parsing from Service to ServiceParser

This is how this should have been done since the beginning.

Test: build, boot
Change-Id: Ifd795776c71a2e666da7fab90cbb3f356af93d4f
diff --git a/init/service.h b/init/service.h
index 0bfc2e6..78f94ce 100644
--- a/init/service.h
+++ b/init/service.h
@@ -14,11 +14,9 @@
  * limitations under the License.
  */
 
-#ifndef _INIT_SERVICE_H
-#define _INIT_SERVICE_H
+#pragma once
 
 #include <signal.h>
-#include <sys/resource.h>
 #include <sys/types.h>
 
 #include <chrono>
@@ -64,6 +62,8 @@
 namespace init {
 
 class Service {
+    friend class ServiceParser;
+
   public:
     Service(const std::string& name, Subcontext* subcontext_for_restart_commands,
             const std::vector<std::string>& args);
@@ -76,7 +76,6 @@
     static std::unique_ptr<Service> MakeTemporaryOneshotService(const std::vector<std::string>& args);
 
     bool IsRunning() { return (flags_ & SVC_RUNNING) != 0; }
-    Result<void> ParseLine(std::vector<std::string>&& args);
     Result<void> ExecStart();
     Result<void> Start();
     Result<void> StartIfNotDisabled();
@@ -130,51 +129,11 @@
     bool is_post_data() const { return post_data_; }
 
   private:
-    using OptionParser = Result<void> (Service::*)(std::vector<std::string>&& args);
-    class OptionParserMap;
-
     void NotifyStateChange(const std::string& new_state) const;
     void StopOrReset(int how);
     void KillProcessGroup(int signal);
     void SetProcessAttributesAndCaps();
 
-    Result<void> ParseCapabilities(std::vector<std::string>&& args);
-    Result<void> ParseClass(std::vector<std::string>&& args);
-    Result<void> ParseConsole(std::vector<std::string>&& args);
-    Result<void> ParseCritical(std::vector<std::string>&& args);
-    Result<void> ParseDisabled(std::vector<std::string>&& args);
-    Result<void> ParseEnterNamespace(std::vector<std::string>&& args);
-    Result<void> ParseGroup(std::vector<std::string>&& args);
-    Result<void> ParsePriority(std::vector<std::string>&& args);
-    Result<void> ParseInterface(std::vector<std::string>&& args);
-    Result<void> ParseIoprio(std::vector<std::string>&& args);
-    Result<void> ParseKeycodes(std::vector<std::string>&& args);
-    Result<void> ParseOneshot(std::vector<std::string>&& args);
-    Result<void> ParseOnrestart(std::vector<std::string>&& args);
-    Result<void> ParseOomScoreAdjust(std::vector<std::string>&& args);
-    Result<void> ParseOverride(std::vector<std::string>&& args);
-    Result<void> ParseMemcgLimitInBytes(std::vector<std::string>&& args);
-    Result<void> ParseMemcgLimitPercent(std::vector<std::string>&& args);
-    Result<void> ParseMemcgLimitProperty(std::vector<std::string>&& args);
-    Result<void> ParseMemcgSoftLimitInBytes(std::vector<std::string>&& args);
-    Result<void> ParseMemcgSwappiness(std::vector<std::string>&& args);
-    Result<void> ParseNamespace(std::vector<std::string>&& args);
-    Result<void> ParseProcessRlimit(std::vector<std::string>&& args);
-    Result<void> ParseRestartPeriod(std::vector<std::string>&& args);
-    Result<void> ParseSeclabel(std::vector<std::string>&& args);
-    Result<void> ParseSetenv(std::vector<std::string>&& args);
-    Result<void> ParseShutdown(std::vector<std::string>&& args);
-    Result<void> ParseSigstop(std::vector<std::string>&& args);
-    Result<void> ParseSocket(std::vector<std::string>&& args);
-    Result<void> ParseTimeoutPeriod(std::vector<std::string>&& args);
-    Result<void> ParseFile(std::vector<std::string>&& args);
-    Result<void> ParseUser(std::vector<std::string>&& args);
-    Result<void> ParseWritepid(std::vector<std::string>&& args);
-    Result<void> ParseUpdatable(std::vector<std::string>&& args);
-
-    template <typename T>
-    Result<void> AddDescriptor(std::vector<std::string>&& args);
-
     static unsigned long next_start_order_;
     static bool is_exec_service_running_;
 
@@ -240,5 +199,3 @@
 
 }  // namespace init
 }  // namespace android
-
-#endif