1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_ARC_SESSION_CONNECTION_OBSERVER_H_ 6 #define COMPONENTS_ARC_SESSION_CONNECTION_OBSERVER_H_ 7 8 namespace arc { 9 namespace internal { 10 11 // Observer to listen events for connection. 12 class ConnectionObserverBase { 13 public: 14 // Called once the connection is ready. 15 // TODO(hidehiko): Currently, this means Instance is ready. 16 // Later, this will be called when Instance::Init() is completed 17 // for ARC full-duplex mojo connection. OnConnectionReady()18 virtual void OnConnectionReady() {} 19 20 // Called once the connection is closed. 21 // Currently, this means Instance is closed. OnConnectionClosed()22 virtual void OnConnectionClosed() {} 23 24 protected: 25 virtual ~ConnectionObserverBase() = default; 26 }; 27 28 } // namespace internal 29 30 // Observer to listen events for connection for specific type. 31 // This is for type safeness to prevent listening events of unexpected mojo 32 // connection. 33 template <typename InstanceType> 34 class ConnectionObserver : public internal::ConnectionObserverBase {}; 35 36 } // namespace arc 37 38 #endif // COMPONENTS_ARC_SESSION_CONNECTION_OBSERVER_H_ 39