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

Side by Side Diff: content/common/service_manager/service_manager_connection_impl.cc

Issue 2695803004: Make browser process a singleton service (Closed)
Patch Set: . Created 3 years, 10 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/service_manager/service_manager_connection_impl.h" 5 #include "content/common/service_manager/service_manager_connection_impl.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 base::Bind(&ServiceManagerConnectionImpl::OnContextInitialized, 432 base::Bind(&ServiceManagerConnectionImpl::OnContextInitialized,
433 weak_factory_.GetWeakPtr()), 433 weak_factory_.GetWeakPtr()),
434 base::Bind(&ServiceManagerConnectionImpl::OnConnect, 434 base::Bind(&ServiceManagerConnectionImpl::OnConnect,
435 weak_factory_.GetWeakPtr()), 435 weak_factory_.GetWeakPtr()),
436 base::Bind(&ServiceManagerConnectionImpl::CreateService, 436 base::Bind(&ServiceManagerConnectionImpl::CreateService,
437 weak_factory_.GetWeakPtr()), 437 weak_factory_.GetWeakPtr()),
438 base::Bind(&ServiceManagerConnectionImpl::OnConnectionLost, 438 base::Bind(&ServiceManagerConnectionImpl::OnConnectionLost,
439 weak_factory_.GetWeakPtr())); 439 weak_factory_.GetWeakPtr()));
440 } 440 }
441 441
442 void ServiceManagerConnectionImpl::SetInitializeHandler(
443 const base::Closure& handler) {
444 DCHECK(initialize_handler_.is_null());
445 initialize_handler_ = handler;
446 }
447
448 service_manager::Connector* ServiceManagerConnectionImpl::GetConnector() { 442 service_manager::Connector* ServiceManagerConnectionImpl::GetConnector() {
449 return connector_.get(); 443 return connector_.get();
450 } 444 }
451 445
452 const service_manager::Identity& ServiceManagerConnectionImpl::GetIdentity() 446 const service_manager::Identity& ServiceManagerConnectionImpl::GetIdentity()
453 const { 447 const {
454 return identity_; 448 return identity_;
455 } 449 }
456 450
457 void ServiceManagerConnectionImpl::SetConnectionLostClosure( 451 void ServiceManagerConnectionImpl::SetConnectionLostClosure(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 service_manager::mojom::ServiceRequest request, 510 service_manager::mojom::ServiceRequest request,
517 const std::string& name) { 511 const std::string& name) {
518 auto it = request_handlers_.find(name); 512 auto it = request_handlers_.find(name);
519 if (it != request_handlers_.end()) 513 if (it != request_handlers_.end())
520 it->second.Run(std::move(request)); 514 it->second.Run(std::move(request));
521 } 515 }
522 516
523 void ServiceManagerConnectionImpl::OnContextInitialized( 517 void ServiceManagerConnectionImpl::OnContextInitialized(
524 const service_manager::Identity& identity) { 518 const service_manager::Identity& identity) {
525 identity_ = identity; 519 identity_ = identity;
526 if (!initialize_handler_.is_null())
527 base::ResetAndReturn(&initialize_handler_).Run();
528 } 520 }
529 521
530 void ServiceManagerConnectionImpl::OnConnectionLost() { 522 void ServiceManagerConnectionImpl::OnConnectionLost() {
531 if (!connection_lost_handler_.is_null()) 523 if (!connection_lost_handler_.is_null())
532 connection_lost_handler_.Run(); 524 connection_lost_handler_.Run();
533 } 525 }
534 526
535 void ServiceManagerConnectionImpl::OnConnect( 527 void ServiceManagerConnectionImpl::OnConnect(
536 const service_manager::ServiceInfo& local_info, 528 const service_manager::ServiceInfo& local_info,
537 const service_manager::ServiceInfo& remote_info) { 529 const service_manager::ServiceInfo& remote_info) {
538 local_info_ = local_info; 530 local_info_ = local_info;
539 for (auto& handler : on_connect_handlers_) 531 for (auto& handler : on_connect_handlers_)
540 handler.second.Run(local_info, remote_info); 532 handler.second.Run(local_info, remote_info);
541 } 533 }
542 534
543 void ServiceManagerConnectionImpl::GetInterface( 535 void ServiceManagerConnectionImpl::GetInterface(
544 service_manager::mojom::InterfaceProvider* provider, 536 service_manager::mojom::InterfaceProvider* provider,
545 const std::string& interface_name, 537 const std::string& interface_name,
546 mojo::ScopedMessagePipeHandle request_handle) { 538 mojo::ScopedMessagePipeHandle request_handle) {
547 provider->GetInterface(interface_name, std::move(request_handle)); 539 provider->GetInterface(interface_name, std::move(request_handle));
548 } 540 }
549 541
550 } // namespace content 542 } // namespace content
551 543
OLDNEW
« no previous file with comments | « content/common/service_manager/service_manager_connection_impl.h ('k') | content/content_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698