Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: components/arc/arc_bridge_service_impl.h

Issue 1481523002: arc-bridge: Split ArcBridgeService to common part and IPC based impl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase issue Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/arc/arc_bridge_service_impl.h
diff --git a/components/arc/arc_bridge_service_impl.h b/components/arc/arc_bridge_service_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..aa7add0f0b428241eba5673779e12f2d67979ed4
--- /dev/null
+++ b/components/arc/arc_bridge_service_impl.h
@@ -0,0 +1,97 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_
+#define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_
+
+#include "base/files/scoped_file.h"
+#include "base/macros.h"
+#include "components/arc/arc_bridge_service.h"
+#include "ipc/ipc_channel_proxy.h"
+#include "ipc/ipc_listener.h"
+#include "ipc/ipc_message.h"
+
+namespace base {
+class SequencedTaskRunner;
+class SingleThreadTaskRunner;
+}
hidehiko 2015/11/26 02:21:51 nit: // namespace base
khmel1 2015/11/26 05:46:43 Done.
+
+namespace arc {
+
+// Real IPC based ArcBridgeService that is used in production.
+class ArcBridgeServiceImpl : public ArcBridgeService,
+ public IPC::Listener {
+ public:
+ ArcBridgeServiceImpl(
+ const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
+ const scoped_refptr<base::SequencedTaskRunner>& file_task_runner);
+ ~ArcBridgeServiceImpl() override;
+
+ void DetectAvailability() override;
+
+ void HandleStartup() override;
+
+ void Shutdown() override;
+
+ bool RegisterInputDevice(const std::string& name,
+ const std::string& device_type,
+ base::ScopedFD fd) override;
+
+ private:
+ friend class ArcBridgeTest;
+ FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic);
+ FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup);
+
+ // If all pre-requisites are true (ARC is available, it has been enabled, and
+ // the session has started), and ARC is stopped, start ARC. If ARC is running
+ // and the pre-requisites stop being true, stop ARC.
+ void PrerequisitesChanged();
+
+ // Binds to the socket specified by |socket_path|.
+ void SocketConnect(const base::FilePath& socket_path);
+
+ // Binds to the socket specified by |socket_path| after creating its parent
+ // directory is present.
+ void SocketConnectAfterEnsureParentDirectory(
+ const base::FilePath& socket_path,
+ bool directory_present);
+
+ // Internal connection method. Separated to make testing easier.
+ bool Connect(const IPC::ChannelHandle& handle, IPC::Channel::Mode mode);
+
+ // Finishes connecting after setting socket permissions.
+ void SocketConnectAfterSetSocketPermissions(const base::FilePath& socket_path,
+ bool socket_permissions_success);
+
+ // Stops the running instance.
+ void StopInstance();
+
+ // Called when the instance has reached a boot phase
+ void OnInstanceBootPhase(InstanceBootPhase phase);
+
+ // IPC::Listener:
+ bool OnMessageReceived(const IPC::Message& message) override;
+
+ // DBus callbacks.
+ void OnArcAvailable(bool available);
+ void OnInstanceStarted(bool success);
+ void OnInstanceStopped(bool success);
+
+ scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_;
+ scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
+
+ scoped_ptr<IPC::ChannelProxy> ipc_channel_;
+
+ // If the user's session has started.
+ bool session_started_;
+
+ // WeakPtrFactory to use callbacks.
+ base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl);
+};
+
+} // namespace arc
+
+#endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698