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

Side by Side Diff: mojo/public/cpp/application/lazy_interface_ptr.h

Issue 423613002: Mojo: split up service_provider.mojom (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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 #ifndef MOJO_PUBLIC_CPP_APPLICATION_LAZY_INTERFACE_PTR_H_ 5 #ifndef MOJO_PUBLIC_CPP_APPLICATION_LAZY_INTERFACE_PTR_H_
6 #define MOJO_PUBLIC_CPP_APPLICATION_LAZY_INTERFACE_PTR_H_ 6 #define MOJO_PUBLIC_CPP_APPLICATION_LAZY_INTERFACE_PTR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "mojo/public/cpp/application/connect.h" 10 #include "mojo/public/cpp/application/connect.h"
11 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" 11 #include "mojo/public/interfaces/application/service_provider.mojom.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 14
15 template<typename Interface> 15 template<typename Interface>
16 class LazyInterfacePtr : InterfacePtr<Interface> { 16 class LazyInterfacePtr : InterfacePtr<Interface> {
17 public: 17 public:
18 LazyInterfacePtr(ServiceProvider* service_provider) 18 LazyInterfacePtr(ServiceProvider* service_provider)
19 : service_provider_(service_provider) { 19 : service_provider_(service_provider) {
20 } 20 }
21 21
22 Interface* get() const { 22 Interface* get() const {
23 if (!InterfacePtr<Interface>::get()) { 23 if (!InterfacePtr<Interface>::get()) {
24 mojo::ConnectToService<Interface>( 24 mojo::ConnectToService<Interface>(
25 service_provider_, 25 service_provider_,
26 const_cast<LazyInterfacePtr<Interface>*>(this)); 26 const_cast<LazyInterfacePtr<Interface>*>(this));
27 } 27 }
28 return InterfacePtr<Interface>::get(); 28 return InterfacePtr<Interface>::get();
29 } 29 }
30 Interface* operator->() const { return get(); } 30 Interface* operator->() const { return get(); }
31 Interface& operator*() const { return *get(); } 31 Interface& operator*() const { return *get(); }
32 32
33 private: 33 private:
34 ServiceProvider* service_provider_; 34 ServiceProvider* service_provider_;
35 }; 35 };
36 36
37 } // namespace mojo 37 } // namespace mojo
38 38
39 #endif // MOJO_PUBLIC_CPP_APPLICATION_LAZY_INTERFACE_PTR_H_ 39 #endif // MOJO_PUBLIC_CPP_APPLICATION_LAZY_INTERFACE_PTR_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/connect.h ('k') | mojo/public/cpp/application/lib/service_connector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698