service: Refactor IPC and singletons
This CL makes the following major refactors to the system service code:
1. A new global Daemon object is introduced, which manages the main event
loop and all other subsystems of the Bluetooth daemon. This object is the only
singleton class and initializes and owns everything else.
2. Everything that was a singleton and/or was initialized directly in main.cpp
is now a) no longer a singleton; b) now initialized and owned by the global
Daemon instance.
3. All of the Chromecast specific IPC code has been moved into the ipc/
subdirectory. This directory is meant for everything that is IPC related,
paving the way for enabling multiple IPC systems (domain-socket based, Binder
based, etc) simultaneously in the future. Main changes to the Chromecast IPC
code are:
a. All files and classes have been renamed to reflect the
UNIX-domain-socket-specific nature of the IPC mechanism.
b. The code no longer hogs up the main thread while listening for
connections. All of this logic has been moved to a dedicated thread with
its own MessageLoopForIO, so that it can use the built-in mechanisms for
polling on client sockets in the future.
Bug: 22532180
Change-Id: I42db06dba6cff3bc8f8101a1ea2b6787a69409fd
diff --git a/service/settings.h b/service/settings.h
index f600465..900408c 100644
--- a/service/settings.h
+++ b/service/settings.h
@@ -31,23 +31,17 @@
// Constant for the "--help" command-line switches.
static const char kHelp[];
- // Initializes Settings from the command-line arguments and switches for the
- // current process. Returns false if initialization fails, for example if an
- // incorrect command-line option has been given.
- static bool Initialize();
-
- // Non-mutable getter for the global Settings object. Use this getter for
- // accessing settings in a read-only fashion (which should be the case for
- // most of the code that wants to use this class).
- static const Settings& Get();
-
- // DO NOT call these directly. Instead, interact with the global instance
- // using the static Initialize and Get methods.
Settings();
~Settings();
// TODO(armansito): Write an instance method for storing things into a file.
+ // Initializes the Settings object. This reads the command-line options for
+ // the current process (which must have been initialized using
+ // base::CommandLine) and sets up the initial global settings. Returns false
+ // if there is an error, e.g. if the parameters/switches are malformed.
+ bool Init();
+
// Path to the unix domain socket for Bluetooth IPC. On Android, this needs to
// match the init provided socket domain prefix. Outside Android, this will be
// the path for the traditional Unix domain socket that the daemon will
@@ -57,9 +51,6 @@
}
private:
- // Instance helper for the static Initialize() method.
- bool Init();
-
bool initialized_;
base::FilePath ipc_socket_path_;