Index: components/arc/arc_bridge_service.h |
diff --git a/components/arc/arc_bridge_service.h b/components/arc/arc_bridge_service.h |
index 12aae9d30f76d063bda8a67dfb05e6add5973802..2baa8b9500e72a3521c8da6d49af7b65f321a01f 100644 |
--- a/components/arc/arc_bridge_service.h |
+++ b/components/arc/arc_bridge_service.h |
@@ -150,6 +150,13 @@ class ArcBridgeService : public ArcBridgeHost { |
ProcessInstance* process_instance() { return process_ptr_.get(); } |
SettingsInstance* settings_instance() { return settings_ptr_.get(); } |
+ int32_t app_version() const { return app_ptr_.version(); } |
+ int32_t input_version() const { return input_ptr_.version(); } |
+ int32_t notifications_version() const { return notifications_ptr_.version(); } |
+ int32_t power_version() const { return power_ptr_.version(); } |
+ int32_t process_version() const { return process_ptr_.version(); } |
+ int32_t settings_version() const { return settings_ptr_.version(); } |
+ |
// ArcHost: |
void OnAppInstanceReady(AppInstancePtr app_ptr) override; |
void OnInputInstanceReady(InputInstancePtr input_ptr) override; |
@@ -184,6 +191,14 @@ class ArcBridgeService : public ArcBridgeHost { |
FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); |
FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); |
+ // Callbacks for QueryVersion. |
+ void OnAppVersionReady(int32_t version); |
+ void OnInputVersionReady(int32_t version); |
+ void OnNotificationsVersionReady(int32_t version); |
+ void OnPowerVersionReady(int32_t version); |
+ void OnProcessVersionReady(int32_t version); |
+ void OnSettingsVersionReady(int32_t version); |
+ |
// Mojo interfaces. |
AppInstancePtr app_ptr_; |
InputInstancePtr input_ptr_; |
@@ -192,6 +207,19 @@ class ArcBridgeService : public ArcBridgeHost { |
ProcessInstancePtr process_ptr_; |
SettingsInstancePtr settings_ptr_; |
+ // Temporary Mojo interfaces. After a Mojo interface pointer has been |
+ // received from the other endpoint, we still need to asynchronously query |
+ // its version. While that is going on, we should still return nullptr on |
+ // the xxx_instance() functions. |
+ // To keep the xxx_instance() functions being trivial, store the instance |
+ // pointer in a temporary variable to avoid losing its reference. |
+ AppInstancePtr temporary_app_ptr_; |
hidehiko
2015/12/29 13:49:20
Instead of making temporary_XXX_ptr_ fields, you c
Luis Héctor Chávez
2015/12/29 16:51:09
That won't work. It would need something like
app
hidehiko
2016/01/05 08:05:52
Ah, you're right. QueryVersion is a member of Inte
|
+ InputInstancePtr temporary_input_ptr_; |
+ NotificationsInstancePtr temporary_notifications_ptr_; |
+ PowerInstancePtr temporary_power_ptr_; |
+ ProcessInstancePtr temporary_process_ptr_; |
+ SettingsInstancePtr temporary_settings_ptr_; |
+ |
base::ObserverList<Observer> observer_list_; |
base::ThreadChecker thread_checker_; |
@@ -202,6 +230,9 @@ class ArcBridgeService : public ArcBridgeHost { |
// The current state of the bridge. |
ArcBridgeService::State state_; |
+ // WeakPtrFactory to use callbacks. |
+ base::WeakPtrFactory<ArcBridgeService> weak_factory_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); |
}; |