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

Side by Side Diff: mojo/public/cpp/application/lib/service_connector.h

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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
(Empty)
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 #ifndef MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_
6 #define MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_
7
8 #include "mojo/public/cpp/application/interface_factory.h"
9 #include "mojo/public/cpp/bindings/interface_request.h"
10
11 namespace mojo {
12 class ApplicationConnection;
13
14 namespace internal {
15
16 class ServiceConnectorBase {
17 public:
18 ServiceConnectorBase(const std::string& name);
19 virtual ~ServiceConnectorBase();
20 virtual void ConnectToService(const std::string& name,
21 ScopedMessagePipeHandle client_handle) = 0;
22 std::string name() const { return name_; }
23 void set_application_connection(ApplicationConnection* connection) {
24 application_connection_ = connection;
25 }
26
27 protected:
28 std::string name_;
29 ApplicationConnection* application_connection_;
30
31 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceConnectorBase);
32 };
33
34 template <typename Interface>
35 class InterfaceFactoryConnector : public ServiceConnectorBase {
36 public:
37 explicit InterfaceFactoryConnector(InterfaceFactory<Interface>* factory)
38 : ServiceConnectorBase(Interface::Name_), factory_(factory) {}
39 virtual ~InterfaceFactoryConnector() {}
40
41 virtual void ConnectToService(const std::string& name,
42 ScopedMessagePipeHandle client_handle) {
43 factory_->Create(application_connection_,
44 MakeRequest<Interface>(client_handle.Pass()));
45 }
46
47 private:
48 InterfaceFactory<Interface>* factory_;
49 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfaceFactoryConnector);
50 };
51
52 } // namespace internal
53 } // namespace mojo
54
55 #endif // MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/lib/application_test_main.cc ('k') | mojo/public/cpp/application/lib/service_connector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698