Home | History | Annotate | Download | only in bindings
      1 // Copyright 2015 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 MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_
      6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_
      7 
      8 #include "base/callback.h"
      9 #include "base/memory/ref_counted.h"
     10 #include "mojo/public/cpp/bindings/bindings_export.h"
     11 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
     12 
     13 namespace mojo {
     14 
     15 class AssociatedGroupController;
     16 
     17 // AssociatedGroup refers to all the interface endpoints running at one end of a
     18 // message pipe.
     19 // It is thread safe and cheap to make copies.
     20 class MOJO_CPP_BINDINGS_EXPORT AssociatedGroup {
     21  public:
     22   AssociatedGroup();
     23 
     24   explicit AssociatedGroup(scoped_refptr<AssociatedGroupController> controller);
     25 
     26   explicit AssociatedGroup(const ScopedInterfaceEndpointHandle& handle);
     27 
     28   AssociatedGroup(const AssociatedGroup& other);
     29 
     30   ~AssociatedGroup();
     31 
     32   AssociatedGroup& operator=(const AssociatedGroup& other);
     33 
     34   // The return value of this getter if this object is initialized with a
     35   // ScopedInterfaceEndpointHandle:
     36   //   - If the handle is invalid, the return value will always be null.
     37   //   - If the handle is valid and non-pending, the return value will be
     38   //     non-null and remain unchanged even if the handle is later reset.
     39   //   - If the handle is pending asssociation, the return value will initially
     40   //     be null, change to non-null when/if the handle is associated, and
     41   //     remain unchanged ever since.
     42   AssociatedGroupController* GetController();
     43 
     44  private:
     45   base::Callback<AssociatedGroupController*()> controller_getter_;
     46   scoped_refptr<AssociatedGroupController> controller_;
     47 };
     48 
     49 }  // namespace mojo
     50 
     51 #endif  // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_
     52