Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: content/common/associated_interface_provider_impl.cc

Issue 2352533003: [Autofill] Migrate ChromePasswordManagerClient<-->PasswordGenerationAgent IPCs to mojo. (Closed)
Patch Set: Address comments from Vaclav Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/common/associated_interface_provider_impl.h" 5 #include "content/common/associated_interface_provider_impl.h"
6 6
7 namespace content { 7 namespace content {
8 8
9 AssociatedInterfaceProviderImpl::LocalProvider::LocalProvider(
10 mojom::AssociatedInterfaceProviderAssociatedPtr* proxy)
11 : route_provider_binding_(this),
12 associated_interface_provider_binding_(this) {
13 route_provider_binding_.Bind(mojo::GetProxy(&route_provider_ptr_));
14 route_provider_ptr_->GetRoute(
15 0, mojo::GetProxy(proxy, route_provider_ptr_.associated_group()));
16 }
17 AssociatedInterfaceProviderImpl::LocalProvider::~LocalProvider() {}
18
19 void AssociatedInterfaceProviderImpl::LocalProvider::SetBinderForName(
20 const std::string& name,
21 const base::Callback<void(mojo::ScopedInterfaceEndpointHandle)>& binder) {
22 binders_[name] = binder;
23 }
24
25 void AssociatedInterfaceProviderImpl::LocalProvider::GetRoute(
26 int32_t routing_id,
27 mojom::AssociatedInterfaceProviderAssociatedRequest request) {
28 DCHECK(request.is_pending());
29 associated_interface_provider_binding_.Bind(std::move(request));
30 }
31
32 void AssociatedInterfaceProviderImpl::LocalProvider::GetAssociatedInterface(
33 const std::string& name,
34 mojom::AssociatedInterfaceAssociatedRequest request) {
35 auto it = binders_.find(name);
36 if (it != binders_.end())
37 it->second.Run(request.PassHandle());
38 }
39
9 AssociatedInterfaceProviderImpl::AssociatedInterfaceProviderImpl( 40 AssociatedInterfaceProviderImpl::AssociatedInterfaceProviderImpl(
10 mojom::AssociatedInterfaceProviderAssociatedPtr proxy) 41 mojom::AssociatedInterfaceProviderAssociatedPtr proxy)
11 : proxy_(std::move(proxy)) { 42 : proxy_(std::move(proxy)) {
43 DCHECK(proxy_.is_bound());
12 } 44 }
13 45
46 AssociatedInterfaceProviderImpl::AssociatedInterfaceProviderImpl()
47 : local_provider_(new LocalProvider(&proxy_)) {}
48
14 AssociatedInterfaceProviderImpl::~AssociatedInterfaceProviderImpl() {} 49 AssociatedInterfaceProviderImpl::~AssociatedInterfaceProviderImpl() {}
15 50
16 void AssociatedInterfaceProviderImpl::GetInterface( 51 void AssociatedInterfaceProviderImpl::GetInterface(
17 const std::string& name, 52 const std::string& name,
18 mojo::ScopedInterfaceEndpointHandle handle) { 53 mojo::ScopedInterfaceEndpointHandle handle) {
19 mojom::AssociatedInterfaceAssociatedRequest request; 54 mojom::AssociatedInterfaceAssociatedRequest request;
20 request.Bind(std::move(handle)); 55 request.Bind(std::move(handle));
21 return proxy_->GetAssociatedInterface(name, std::move(request)); 56 return proxy_->GetAssociatedInterface(name, std::move(request));
22 } 57 }
23 58
24 mojo::AssociatedGroup* AssociatedInterfaceProviderImpl::GetAssociatedGroup() { 59 mojo::AssociatedGroup* AssociatedInterfaceProviderImpl::GetAssociatedGroup() {
25 return proxy_.associated_group(); 60 return proxy_.associated_group();
26 } 61 }
27 62
63 void AssociatedInterfaceProviderImpl::OverrideBinderForTesting(
64 const std::string& name,
65 const base::Callback<void(mojo::ScopedInterfaceEndpointHandle)>& binder) {
66 DCHECK(local_provider_);
67 local_provider_->SetBinderForName(name, binder);
68 }
69
28 } // namespace content 70 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698