OSDN Git Service

service: Move UNIX IPC code into ipc/unix/
authorArman Uguray <armansito@google.com>
Thu, 20 Aug 2015 20:07:18 +0000 (13:07 -0700)
committerArman Uguray <armansito@google.com>
Thu, 20 Aug 2015 20:07:18 +0000 (13:07 -0700)
Moved the UNIX IPC related code into a new ipc/unix subdirectory.
Added new namespace levels for unix and binder that mimic the
directory structure.

Change-Id: I58954d0c3dd1a6fe9c141c3122d42530385265f6

service/Android.mk
service/ipc/binder/ipc_handler_binder.cpp
service/ipc/binder/ipc_handler_binder.h
service/ipc/ipc_manager.cpp
service/ipc/unix/ipc_handler_unix.cpp [moved from service/ipc/ipc_handler_unix.cpp with 98% similarity]
service/ipc/unix/ipc_handler_unix.h [moved from service/ipc/ipc_handler_unix.h with 98% similarity]
service/ipc/unix/unix_ipc_host.cpp [moved from service/ipc/unix_ipc_host.cpp with 99% similarity]
service/ipc/unix/unix_ipc_host.h [moved from service/ipc/unix_ipc_host.h with 98% similarity]
service/test/stub_ipc_handler_binder.cpp

index 956e534..d6de98b 100644 (file)
@@ -25,9 +25,9 @@ btserviceCommonSrc := \
        gatt_server.cpp \
        hal/bluetooth_interface.cpp \
        ipc/ipc_handler.cpp \
-       ipc/ipc_handler_unix.cpp \
        ipc/ipc_manager.cpp \
-       ipc/unix_ipc_host.cpp \
+       ipc/unix/ipc_handler_unix.cpp \
+       ipc/unix/unix_ipc_host.cpp \
        logging_helpers.cpp \
        settings.cpp \
        util/atomic_string.cpp \
index 46e8a5f..bb97d38 100644 (file)
@@ -31,6 +31,7 @@ using android::status_t;
 using android::String16;
 
 namespace ipc {
+namespace binder {
 
 IPCHandlerBinder::IPCHandlerBinder(
     bluetooth::Adapter* adapter,
@@ -79,4 +80,5 @@ void IPCHandlerBinder::NotifyStarted() {
     delegate()->OnIPCHandlerStarted(IPCManager::TYPE_BINDER);
 }
 
+}  // namespace binder
 }  // namespace ipc
index ef8621b..3a8931f 100644 (file)
@@ -22,6 +22,7 @@
 #include "service/ipc/ipc_manager.h"
 
 namespace ipc {
+namespace binder {
 
 // Implements a Binder based IPCHandler.
 class IPCHandlerBinder : public IPCHandler {
@@ -43,4 +44,5 @@ class IPCHandlerBinder : public IPCHandler {
   DISALLOW_COPY_AND_ASSIGN(IPCHandlerBinder);
 };
 
+}  // namespace binder
 }  // namespace ipc
index 40d57a3..aeabd1f 100644 (file)
@@ -17,7 +17,7 @@
 #include "service/ipc/ipc_manager.h"
 
 #include "service/ipc/binder/ipc_handler_binder.h"
-#include "service/ipc/ipc_handler_unix.h"
+#include "service/ipc/unix/ipc_handler_unix.h"
 
 namespace ipc {
 
@@ -43,7 +43,7 @@ bool IPCManager::Start(Type type, Delegate* delegate) {
       return false;
     }
 
-    unix_handler_ = new IPCHandlerUnix(adapter_, delegate);
+    unix_handler_ = new unix::IPCHandlerUnix(adapter_, delegate);
     if (!unix_handler_->Run()) {
       unix_handler_ = nullptr;
       return false;
@@ -56,7 +56,7 @@ bool IPCManager::Start(Type type, Delegate* delegate) {
       return false;
     }
 
-    binder_handler_ = new IPCHandlerBinder(adapter_, delegate);
+    binder_handler_ = new binder::IPCHandlerBinder(adapter_, delegate);
     if (!binder_handler_->Run()) {
       binder_handler_ = nullptr;
       return false;
similarity index 98%
rename from service/ipc/ipc_handler_unix.cpp
rename to service/ipc/unix/ipc_handler_unix.cpp
index eaba84d..a847e9b 100644 (file)
@@ -14,7 +14,7 @@
 //  limitations under the License.
 //
 
-#include "service/ipc/ipc_handler_unix.h"
+#include "service/ipc/unix/ipc_handler_unix.h"
 
 #include <sys/socket.h>
 #include <sys/un.h>
 
 #include "osi/include/socket_utils/sockets.h"
 #include "service/daemon.h"
-#include "service/ipc/unix_ipc_host.h"
+#include "service/ipc/unix/unix_ipc_host.h"
 #include "service/settings.h"
 
 namespace ipc {
+namespace unix {
 
 IPCHandlerUnix::IPCHandlerUnix(bluetooth::Adapter* adapter,
                                IPCManager::Delegate* delegate)
@@ -212,4 +213,5 @@ void IPCHandlerUnix::NotifyStoppedOnCurrentThread() {
     delegate()->OnIPCHandlerStopped(IPCManager::TYPE_UNIX);
 }
 
+}  // namespace unix
 }  // namespace ipc
similarity index 98%
rename from service/ipc/ipc_handler_unix.h
rename to service/ipc/unix/ipc_handler_unix.h
index 4b91740..da3913c 100644 (file)
@@ -31,6 +31,7 @@ class SingleThreadTaskRunner;
 }  // namespace base
 
 namespace ipc {
+namespace unix {
 
 // Implements a UNIX domain-socket based IPCHandler
 class IPCHandlerUnix : public IPCHandler {
@@ -83,4 +84,5 @@ class IPCHandlerUnix : public IPCHandler {
   DISALLOW_COPY_AND_ASSIGN(IPCHandlerUnix);
 };
 
+}  // namespace unix
 }  // namespace ipc
similarity index 99%
rename from service/ipc/unix_ipc_host.cpp
rename to service/ipc/unix/unix_ipc_host.cpp
index 2f801d4..ee284fb 100644 (file)
@@ -16,7 +16,7 @@
 
 #define LOG_TAG "bt_bluetooth_host"
 
-#include "service/ipc/unix_ipc_host.h"
+#include "service/ipc/unix/unix_ipc_host.h"
 
 #include <errno.h>
 #include <stdio.h>
@@ -74,6 +74,7 @@ bool TokenBool(const std::string& text) {
 }  // namespace
 
 namespace ipc {
+namespace unix {
 
 UnixIPCHost::UnixIPCHost(int sockfd, Adapter* adapter)
     : adapter_(adapter), pfds_(1, {sockfd, POLLIN, 0}) {}
@@ -336,4 +337,5 @@ bool UnixIPCHost::OnGattWrite() {
   return true;
 }
 
+}  // namespace unix
 }  // namespace ipc
similarity index 98%
rename from service/ipc/unix_ipc_host.h
rename to service/ipc/unix/unix_ipc_host.h
index 1ebf60a..af84db4 100644 (file)
@@ -29,6 +29,7 @@ class Adapter;
 }  // namespace bluetooth
 
 namespace ipc {
+namespace unix {
 
 // This implements a single threaded event loop which dispatches
 // reads from a set of FDs (pfds_) to a set of handlers.
@@ -104,4 +105,5 @@ class UnixIPCHost {
       gatt_servers_;
 };
 
+}  // namespace unix
 }  // namespace ipc
index 6f5a13d..a1e7874 100644 (file)
@@ -21,6 +21,7 @@
 // unit tests for host.
 
 namespace ipc {
+namespace binder {
 
 IPCHandlerBinder::IPCHandlerBinder(
     bluetooth::Adapter* adapter,
@@ -46,4 +47,5 @@ void IPCHandlerBinder::NotifyStarted() {
   // Stub
 }
 
-}  // namespace
+}  // namespace binder
+}  // namespace ipc