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

Side by Side Diff: services/shell/public/cpp/lib/interface_registry.cc

Issue 2108343002: Defer Mojo interface binding in the gpu process until OnInitialize (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « services/shell/public/cpp/interface_registry.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "services/shell/public/cpp/interface_registry.h" 5 #include "services/shell/public/cpp/interface_registry.h"
6 6
7 #include "services/shell/public/cpp/connection.h" 7 #include "services/shell/public/cpp/connection.h"
8 8
9 namespace shell { 9 namespace shell {
10 10
(...skipping 20 matching lines...) Expand all
31 new internal::GenericCallbackBinder(callback, task_runner)), 31 new internal::GenericCallbackBinder(callback, task_runner)),
32 name); 32 name);
33 } 33 }
34 34
35 void InterfaceRegistry::RemoveInterface(const std::string& name) { 35 void InterfaceRegistry::RemoveInterface(const std::string& name) {
36 auto it = name_to_binder_.find(name); 36 auto it = name_to_binder_.find(name);
37 if (it != name_to_binder_.end()) 37 if (it != name_to_binder_.end())
38 name_to_binder_.erase(it); 38 name_to_binder_.erase(it);
39 } 39 }
40 40
41 void InterfaceRegistry::PauseBinding() {
42 DCHECK(!pending_request_.is_pending());
43 DCHECK(binding_.is_bound());
44 pending_request_ = binding_.Unbind();
45 }
46
47 void InterfaceRegistry::ResumeBinding() {
48 DCHECK(pending_request_.is_pending());
49 DCHECK(!binding_.is_bound());
50 binding_.Bind(std::move(pending_request_));
51 }
52
41 // mojom::InterfaceProvider: 53 // mojom::InterfaceProvider:
42 void InterfaceRegistry::GetInterface(const mojo::String& interface_name, 54 void InterfaceRegistry::GetInterface(const mojo::String& interface_name,
43 mojo::ScopedMessagePipeHandle handle) { 55 mojo::ScopedMessagePipeHandle handle) {
44 auto iter = name_to_binder_.find(interface_name); 56 auto iter = name_to_binder_.find(interface_name);
45 if (iter != name_to_binder_.end()) { 57 if (iter != name_to_binder_.end()) {
46 iter->second->BindInterface(connection_, interface_name, std::move(handle)); 58 iter->second->BindInterface(connection_, interface_name, std::move(handle));
47 } else if (connection_ && !connection_->AllowsInterface(interface_name)) { 59 } else if (connection_ && !connection_->AllowsInterface(interface_name)) {
48 LOG(ERROR) << "Connection CapabilityFilter prevented binding to " 60 LOG(ERROR) << "Connection CapabilityFilter prevented binding to "
49 << "interface: " << interface_name << " connection_name:" 61 << "interface: " << interface_name << " connection_name:"
50 << connection_->GetConnectionName() << " remote_name:" 62 << connection_->GetConnectionName() << " remote_name:"
51 << connection_->GetRemoteIdentity().name(); 63 << connection_->GetRemoteIdentity().name();
52 } 64 }
53 } 65 }
54 66
55 bool InterfaceRegistry::SetInterfaceBinderForName( 67 bool InterfaceRegistry::SetInterfaceBinderForName(
56 std::unique_ptr<InterfaceBinder> binder, 68 std::unique_ptr<InterfaceBinder> binder,
57 const std::string& interface_name) { 69 const std::string& interface_name) {
58 if (!connection_ || 70 if (!connection_ ||
59 (connection_ && connection_->AllowsInterface(interface_name))) { 71 (connection_ && connection_->AllowsInterface(interface_name))) {
60 RemoveInterface(interface_name); 72 RemoveInterface(interface_name);
61 name_to_binder_[interface_name] = std::move(binder); 73 name_to_binder_[interface_name] = std::move(binder);
62 return true; 74 return true;
63 } 75 }
64 return false; 76 return false;
65 } 77 }
66 78
67 } // namespace shell 79 } // namespace shell
OLDNEW
« no previous file with comments | « services/shell/public/cpp/interface_registry.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698