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 #include "mojo/public/cpp/bindings/associated_group.h" |
12 | 13 |
13 namespace content { | 14 namespace content { |
14 | 15 |
16 namespace { | |
17 class LocalProvider; | |
Ken Rockot(use gerrit already)
2016/09/20 18:26:19
Never use anonymous namespaces in headers.
LocalP
leonhsl(Using Gerrit)
2016/09/21 11:46:57
Done.
| |
18 } | |
19 | |
15 class AssociatedInterfaceProviderImpl : public AssociatedInterfaceProvider { | 20 class AssociatedInterfaceProviderImpl : public AssociatedInterfaceProvider { |
16 public: | 21 public: |
17 // Binds this to a remote mojom::AssociatedInterfaceProvider. | 22 // Binds this to a remote mojom::AssociatedInterfaceProvider. |
18 explicit AssociatedInterfaceProviderImpl( | 23 explicit AssociatedInterfaceProviderImpl( |
19 mojom::AssociatedInterfaceProviderAssociatedPtr proxy); | 24 mojom::AssociatedInterfaceProviderAssociatedPtr proxy); |
25 // This constructor is only used for some tests when there has no injected | |
26 // mojom::AssociatedInterfaceProviderAssociatedPtr. Here will emulate it | |
27 // by providing self-contained local implementations of both | |
28 // mojom::RouteProvider and mojom::AssociatedInterfaceProvider. | |
29 AssociatedInterfaceProviderImpl(); | |
20 ~AssociatedInterfaceProviderImpl() override; | 30 ~AssociatedInterfaceProviderImpl() override; |
21 | 31 |
22 // AssociatedInterfaceProvider: | 32 // AssociatedInterfaceProvider: |
23 void GetInterface(const std::string& name, | 33 void GetInterface(const std::string& name, |
24 mojo::ScopedInterfaceEndpointHandle handle) override; | 34 mojo::ScopedInterfaceEndpointHandle handle) override; |
25 mojo::AssociatedGroup* GetAssociatedGroup() override; | 35 mojo::AssociatedGroup* GetAssociatedGroup() override; |
26 | 36 |
27 private: | 37 private: |
38 void SetBinderForName( | |
39 const std::string& name, | |
40 const base::Callback<void(mojo::ScopedInterfaceEndpointHandle)>& binder) | |
41 override; | |
42 void ClearBinders() override; | |
43 | |
28 mojom::AssociatedInterfaceProviderAssociatedPtr proxy_; | 44 mojom::AssociatedInterfaceProviderAssociatedPtr proxy_; |
29 | 45 |
46 std::unique_ptr<LocalProvider> local_provider_; | |
47 | |
30 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfaceProviderImpl); | 48 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfaceProviderImpl); |
31 }; | 49 }; |
32 | 50 |
33 } // namespace content | 51 } // namespace content |
OLD | NEW |