OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "mojo/public/cpp/application/lib/weak_service_provider.h" | 5 #include "mojo/public/cpp/application/lib/weak_service_provider.h" |
| 6 |
| 7 #include "mojo/public/cpp/application/service_provider_impl.h" |
6 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 8 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
7 | 9 |
8 namespace mojo { | 10 namespace mojo { |
9 namespace internal { | 11 namespace internal { |
10 | 12 |
11 WeakServiceProvider::WeakServiceProvider(ServiceProvider* service_provider) | 13 WeakServiceProvider::WeakServiceProvider(ServiceProviderImpl* creator, |
12 : service_provider_(service_provider) {} | 14 ServiceProvider* service_provider) |
| 15 : creator_(creator), |
| 16 service_provider_(service_provider) {} |
13 | 17 |
14 WeakServiceProvider::~WeakServiceProvider() {} | 18 WeakServiceProvider::~WeakServiceProvider() { |
| 19 if (creator_) |
| 20 creator_->ClearRemote(); |
| 21 } |
15 | 22 |
16 void WeakServiceProvider::Clear() { | 23 void WeakServiceProvider::Clear() { |
| 24 creator_ = NULL; |
17 service_provider_ = NULL; | 25 service_provider_ = NULL; |
18 } | 26 } |
19 | 27 |
20 void WeakServiceProvider::ConnectToService( | 28 void WeakServiceProvider::ConnectToService( |
21 const String& service_name, | 29 const String& service_name, |
22 ScopedMessagePipeHandle client_handle) { | 30 ScopedMessagePipeHandle client_handle) { |
23 if (service_provider_) | 31 if (service_provider_) |
24 service_provider_->ConnectToService(service_name, client_handle.Pass()); | 32 service_provider_->ConnectToService(service_name, client_handle.Pass()); |
25 } | 33 } |
26 | 34 |
27 } // namespace internal | 35 } // namespace internal |
28 } // namespace mojo | 36 } // namespace mojo |
OLD | NEW |