• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "mojo/public/cpp/application/lib/weak_service_provider.h"
6 
7 #include "mojo/public/cpp/application/service_provider_impl.h"
8 #include "mojo/public/interfaces/application/service_provider.mojom.h"
9 
10 namespace mojo {
11 namespace internal {
12 
WeakServiceProvider(ServiceProviderImpl * creator,ServiceProvider * service_provider)13 WeakServiceProvider::WeakServiceProvider(ServiceProviderImpl* creator,
14                                          ServiceProvider* service_provider)
15       : creator_(creator),
16         service_provider_(service_provider) {}
17 
~WeakServiceProvider()18 WeakServiceProvider::~WeakServiceProvider() {
19   if (creator_)
20     creator_->ClearRemote();
21 }
22 
Clear()23 void WeakServiceProvider::Clear() {
24   creator_ = NULL;
25   service_provider_ = NULL;
26 }
27 
ConnectToService(const String & service_name,ScopedMessagePipeHandle client_handle)28 void WeakServiceProvider::ConnectToService(
29     const String& service_name,
30     ScopedMessagePipeHandle client_handle) {
31   if (service_provider_)
32     service_provider_->ConnectToService(service_name, client_handle.Pass());
33 }
34 
35 }  // namespace internal
36 }  // namespace mojo
37