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

Unified Diff: components/arc/arc_bridge_service_impl.h

Issue 1475563002: arc-bridge: Implement IPC message for app launcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use creator for ArcBridgeService 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..1055829df930c508e189059b6feb214ce009f3bb
--- /dev/null
+++ b/components/arc/arc_bridge_service_impl.h
@@ -0,0 +1,121 @@
+// 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;
+}
+
+namespace arc {
+
+// Real IPC based ArcBridgeService that is used in production.
+class ArcBridgeServiceImpl : public ArcBridgeService,
+ public IPC::Listener {
+ public:
+
hidehiko 2015/11/25 07:47:37 Unnecessary space.
khmel1 2015/11/25 15:28:31 Done.
hidehiko 2015/11/26 03:47:22 Not done yet.
khmel1 2015/11/27 05:24:01 Was done in prev CL. updated here
+ 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;
+
+ // Requests to refresh an app list.
+ bool RefreshApps() override;
+
+ // Requests to launch an app.
+ bool LaunchApp(const std::string& package,
+ const std::string& activity) override;
+
+ // Request to load icon of specific scale_factor.
+ bool RequestIcon(const std::string& package,
+ const std::string& activity,
+ int scale_factor) 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);
+
+ // Called whenever ARC sends information about available apps.
+ void OnAppsRefreshed(const std::vector<std::string>& name,
+ const std::vector<std::string>& packages,
+ const std::vector<std::string>& activities);
+
+ // Called whenever ARC sends app icon data for specific scale factor.
+ void OnAppIcon(const std::string& package,
+ const std::string& activity,
+ int scale_factor,
+ const std::vector<uint8_t>& icon_png_data);
+
+ // 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