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

Side by Side Diff: mojo/service_manager/service_manager.h

Issue 265793015: Mojo: Replace RemotePtr with InterfacePtr and InterfaceImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_SERVICE_MANAGER_SERVICE_MANAGER_H_ 5 #ifndef MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_
6 #define MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ 6 #define MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "mojo/public/interfaces/shell/shell.mojom.h" 13 #include "mojo/public/interfaces/shell/shell.mojom.h"
14 #include "mojo/service_manager/service_loader.h" 14 #include "mojo/service_manager/service_loader.h"
15 #include "mojo/service_manager/service_manager_export.h" 15 #include "mojo/service_manager/service_manager_export.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace mojo { 18 namespace mojo {
19 19
20 class MOJO_SERVICE_MANAGER_EXPORT ServiceManager { 20 class MOJO_SERVICE_MANAGER_EXPORT ServiceManager {
21 public: 21 public:
22 // API for testing. 22 // API for testing.
23 class MOJO_SERVICE_MANAGER_EXPORT TestAPI { 23 class MOJO_SERVICE_MANAGER_EXPORT TestAPI {
24 public: 24 public:
25 explicit TestAPI(ServiceManager* manager); 25 explicit TestAPI(ServiceManager* manager);
26 ~TestAPI(); 26 ~TestAPI();
27 27
28 // Returns a handle to the shell. 28 // Returns a handle to a unique shell instance.
29 ScopedShellHandle GetShellHandle(); 29 ScopedMessagePipeHandle GetShellHandle();
30 30
31 // Returns true if the shared instance has been created. 31 // Returns true if the shared instance has been created.
32 static bool HasCreatedInstance(); 32 static bool HasCreatedInstance();
33 // Returns true if there is a ServiceFactory for this URL. 33 // Returns true if there is a ServiceFactory for this URL.
34 bool HasFactoryForURL(const GURL& url) const; 34 bool HasFactoryForURL(const GURL& url) const;
35 35
36 private: 36 private:
37 class TestShellConnection; 37 class TestShellConnection;
38 38
39 ServiceManager* manager_; 39 ServiceManager* manager_;
40 40 scoped_ptr<TestShellConnection> shell_;
41 scoped_ptr<TestShellConnection> shell_connection_;
42 41
43 DISALLOW_COPY_AND_ASSIGN(TestAPI); 42 DISALLOW_COPY_AND_ASSIGN(TestAPI);
44 }; 43 };
45 44
46 // Interface class for debugging only. 45 // Interface class for debugging only.
47 class Interceptor { 46 class Interceptor {
48 public: 47 public:
49 virtual ~Interceptor() {} 48 virtual ~Interceptor() {}
50 // Called when ServiceManager::Connect is called. 49 // Called when ServiceManager::Connect is called.
51 virtual ScopedMessagePipeHandle OnConnectToClient( 50 virtual ScopedMessagePipeHandle OnConnectToClient(
(...skipping 26 matching lines...) Expand all
78 class ServiceFactory; 77 class ServiceFactory;
79 typedef std::map<std::string, ServiceLoader*> SchemeToLoaderMap; 78 typedef std::map<std::string, ServiceLoader*> SchemeToLoaderMap;
80 typedef std::map<GURL, ServiceLoader*> URLToLoaderMap; 79 typedef std::map<GURL, ServiceLoader*> URLToLoaderMap;
81 typedef std::map<GURL, ServiceFactory*> URLToServiceFactoryMap; 80 typedef std::map<GURL, ServiceFactory*> URLToServiceFactoryMap;
82 81
83 // Returns the Loader to use for a url (using default if not overridden.) 82 // Returns the Loader to use for a url (using default if not overridden.)
84 // The preference is to use a loader that's been specified for an url first, 83 // The preference is to use a loader that's been specified for an url first,
85 // then one that's been specified for a scheme, then the default. 84 // then one that's been specified for a scheme, then the default.
86 ServiceLoader* GetLoaderForURL(const GURL& url); 85 ServiceLoader* GetLoaderForURL(const GURL& url);
87 86
88 // Removes a ServiceFactory when it no longer has any connections. 87 // Removes a ServiceFactory when it encounters an error.
89 void OnServiceFactoryError(ServiceFactory* service_factory); 88 void OnServiceFactoryError(ServiceFactory* service_factory);
90 89
91 // Loader management. 90 // Loader management.
92 URLToLoaderMap url_to_loader_; 91 URLToLoaderMap url_to_loader_;
93 SchemeToLoaderMap scheme_to_loader_; 92 SchemeToLoaderMap scheme_to_loader_;
94 scoped_ptr<ServiceLoader> default_loader_; 93 scoped_ptr<ServiceLoader> default_loader_;
95 Interceptor* interceptor_; 94 Interceptor* interceptor_;
96 95
97 URLToServiceFactoryMap url_to_service_factory_; 96 URLToServiceFactoryMap url_to_service_factory_;
98 DISALLOW_COPY_AND_ASSIGN(ServiceManager); 97 DISALLOW_COPY_AND_ASSIGN(ServiceManager);
99 }; 98 };
100 99
101 } // namespace mojo 100 } // namespace mojo
102 101
103 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ 102 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698