Index: components/arc/arc_bridge_service.h |
diff --git a/components/arc/arc_bridge_service.h b/components/arc/arc_bridge_service.h |
index 8d23d44da7cea9fe21c00f3cbb00f2113b128f52..eb2fa31694ad2fb0d0daf0a59d22019f5e3b8140 100644 |
--- a/components/arc/arc_bridge_service.h |
+++ b/components/arc/arc_bridge_service.h |
@@ -5,20 +5,22 @@ |
#ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
#define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
+#include "base/files/scoped_file.h" |
#include "base/macros.h" |
#include "base/observer_list.h" |
-#include "base/sequenced_task_runner.h" |
#include "components/arc/common/arc_message_types.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 { |
// The Chrome-side service that handles ARC instances and ARC bridge creation. |
// This service handles the lifetime of ARC instances and sets up the |
// communication channel (the ARC bridge) used to send and receive messages. |
-class ArcBridgeService : public IPC::Listener { |
+class ArcBridgeService { |
public: |
// The possible states of the bridge. In the normal flow, the state changes |
// in the following sequence: |
@@ -71,14 +73,28 @@ class ArcBridgeService : public IPC::Listener { |
// Called whenever ARC's availability has changed for this system. |
virtual void OnAvailableChanged(bool available) {} |
+ // Called whenever ARC sends information about available apps. |
+ virtual 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. |
+ virtual void OnAppIcon(const std::string& package, |
+ const std::string& activity, |
+ int scale_factor, |
+ const std::vector<uint8_t>& icon_png_data) {} |
dcheng
2015/11/25 06:34:07
Where does icon_png_data originate from? Is this s
khmel1
2015/11/25 06:51:08
This png is encoded in Android: https://googleplex
dcheng
2015/11/25 19:34:55
Would it be feasible to decode here and just pass
khmel1
2015/11/27 05:24:01
I already responded early, just for consistency:
W
dcheng
2015/11/27 05:39:56
That doesn't seem like it'd require multiple obser
khmel1
2015/11/27 05:53:16
Sorry, I don't clear understand your thoughts. Wha
|
+ |
protected: |
virtual ~Observer() {} |
}; |
- ArcBridgeService( |
+ ArcBridgeService(); |
hidehiko
2015/11/25 07:47:37
Please move them to protected section.
khmel1
2015/11/25 15:28:31
scoped_ptr<ArcBridgeService> requires public acces
hidehiko
2015/11/26 03:47:22
For dtor, yes. But it should not requires ctors, I
khmel1
2015/11/27 05:24:01
Done, Was addressed in previous CL
|
+ virtual ~ArcBridgeService(); |
+ |
+ // Create instance of |ArcBridgeService| for normal use. |
+ static ArcBridgeService* Create( |
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, |
const scoped_refptr<base::SequencedTaskRunner>& file_task_runner); |
- ~ArcBridgeService() override; |
// Gets the global instance of the ARC Bridge Service. This can only be |
// called on the thread that this class was created on. |
@@ -87,16 +103,16 @@ class ArcBridgeService : public IPC::Listener { |
// DetectAvailability() should be called once D-Bus is available. It will |
// call CheckArcAvailability() on the session_manager. This can only be |
// called on the thread that this class was created on. |
- void DetectAvailability(); |
+ virtual void DetectAvailability() = 0; |
// HandleStartup() should be called upon profile startup. This will only |
// launch an instance if the instance service is available and it is enabled. |
// This can only be called on the thread that this class was created on. |
- void HandleStartup(); |
+ virtual void HandleStartup() = 0; |
// Shutdown() should be called when the browser is shutting down. This can |
// only be called on the thread that this class was created on. |
- void Shutdown(); |
+ virtual void Shutdown() = 0; |
// Adds or removes observers. This can only be called on the thread that this |
// class was created on. |
@@ -115,73 +131,39 @@ class ArcBridgeService : public IPC::Listener { |
// OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard") |
// and |fd| a file descriptor that emulates the kernel events of the device. |
// This can only be called on the thread that this class was created on. |
- bool RegisterInputDevice(const std::string& name, |
- const std::string& device_type, |
- base::ScopedFD fd); |
- |
- 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); |
+ virtual bool RegisterInputDevice(const std::string& name, |
+ const std::string& device_type, |
+ base::ScopedFD fd) = 0; |
- // 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); |
+ // Requests to refresh an app list. |
+ virtual bool RefreshApps() = 0; |
- // Internal connection method. Separated to make testing easier. |
- bool Connect(const IPC::ChannelHandle& handle, IPC::Channel::Mode mode); |
+ // Requests to launch an app. |
+ virtual bool LaunchApp(const std::string& package, |
+ const std::string& activity) = 0; |
- // 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); |
+ // Request to load icon of specific scale_factor. |
+ virtual bool RequestIcon(const std::string& package, |
+ const std::string& activity, |
+ int scale_factor) = 0; |
+ protected: |
// Changes the current state and notifies all observers. |
void SetState(State state); |
- // IPC::Listener: |
- bool OnMessageReceived(const IPC::Message& message) override; |
- |
- // DBus callbacks. |
- void OnArcAvailable(bool available); |
- void OnInstanceStarted(bool success); |
- void OnInstanceStopped(bool success); |
+ // Changes the current availability and notifies all observers. |
+ void SetAvailable(bool availability); |
scoped_refptr<base::SequencedTaskRunner> origin_task_runner_; |
- scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; |
- scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
- |
- scoped_ptr<IPC::ChannelProxy> ipc_channel_; |
base::ObserverList<Observer> observer_list_; |
- // If the user's session has started. |
- bool session_started_; |
- |
// If the ARC instance service is available. |
bool available_; |
// The current state of the bridge. |
ArcBridgeService::State state_; |
- // WeakPtrFactory to use callbacks. |
- base::WeakPtrFactory<ArcBridgeService> weak_factory_; |
- |
DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); |
}; |