| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/public/common/associated_interface_provider.h" | 5 #include "content/public/common/associated_interface_provider.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <memory> |
| 8 | 9 |
| 9 #include "base/macros.h" | 10 #include "base/macros.h" |
| 10 #include "content/common/associated_interfaces.mojom.h" | 11 #include "content/common/associated_interfaces.mojom.h" |
| 11 #include "mojo/public/cpp/bindings/associated_group.h" | |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 class AssociatedInterfaceProviderImpl : public AssociatedInterfaceProvider { | 15 class AssociatedInterfaceProviderImpl : public AssociatedInterfaceProvider { |
| 16 public: | 16 public: |
| 17 // Binds this to a remote mojom::AssociatedInterfaceProvider. | 17 // Binds this to a remote mojom::AssociatedInterfaceProvider. |
| 18 explicit AssociatedInterfaceProviderImpl( | 18 explicit AssociatedInterfaceProviderImpl( |
| 19 mojom::AssociatedInterfaceProviderAssociatedPtr proxy); | 19 mojom::AssociatedInterfaceProviderAssociatedPtr proxy); |
| 20 // Constructs a local provider with no remote interfaces. This is useful in |
| 21 // conjunction with OverrideBinderForTesting(), in test environments where |
| 22 // there may not be a remote |mojom::AssociatedInterfaceProvider| available. |
| 23 AssociatedInterfaceProviderImpl(); |
| 20 ~AssociatedInterfaceProviderImpl() override; | 24 ~AssociatedInterfaceProviderImpl() override; |
| 21 | 25 |
| 22 // AssociatedInterfaceProvider: | 26 // AssociatedInterfaceProvider: |
| 23 void GetInterface(const std::string& name, | 27 void GetInterface(const std::string& name, |
| 24 mojo::ScopedInterfaceEndpointHandle handle) override; | 28 mojo::ScopedInterfaceEndpointHandle handle) override; |
| 25 mojo::AssociatedGroup* GetAssociatedGroup() override; | 29 mojo::AssociatedGroup* GetAssociatedGroup() override; |
| 30 void OverrideBinderForTesting( |
| 31 const std::string& name, |
| 32 const base::Callback<void(mojo::ScopedInterfaceEndpointHandle)>& binder) |
| 33 override; |
| 26 | 34 |
| 27 private: | 35 private: |
| 36 class LocalProvider; |
| 37 |
| 28 mojom::AssociatedInterfaceProviderAssociatedPtr proxy_; | 38 mojom::AssociatedInterfaceProviderAssociatedPtr proxy_; |
| 29 | 39 |
| 40 std::unique_ptr<LocalProvider> local_provider_; |
| 41 |
| 30 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfaceProviderImpl); | 42 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfaceProviderImpl); |
| 31 }; | 43 }; |
| 32 | 44 |
| 33 } // namespace content | 45 } // namespace content |
| OLD | NEW |