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 #include "mojo/public/cpp/bindings/associated_group.h"
6 
7 #include "mojo/public/cpp/bindings/associated_group_controller.h"
8 
9 namespace mojo {
10 
11 AssociatedGroup::AssociatedGroup() = default;
12 
AssociatedGroup(scoped_refptr<AssociatedGroupController> controller)13 AssociatedGroup::AssociatedGroup(
14     scoped_refptr<AssociatedGroupController> controller)
15     : controller_(std::move(controller)) {}
16 
AssociatedGroup(const ScopedInterfaceEndpointHandle & handle)17 AssociatedGroup::AssociatedGroup(const ScopedInterfaceEndpointHandle& handle)
18     : controller_getter_(handle.CreateGroupControllerGetter()) {}
19 
20 AssociatedGroup::AssociatedGroup(const AssociatedGroup& other) = default;
21 
22 AssociatedGroup::~AssociatedGroup() = default;
23 
24 AssociatedGroup& AssociatedGroup::operator=(const AssociatedGroup& other) =
25     default;
26 
GetController()27 AssociatedGroupController* AssociatedGroup::GetController() {
28   if (controller_)
29     return controller_.get();
30 
31   return controller_getter_.Run();
32 }
33 
34 }  // namespace mojo
35