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

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

Issue 225203002: Mojo Spy core first cut (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: first version Created 6 years, 8 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/callback.h" 11 #include "base/callback.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.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_manager_export.h" 14 #include "mojo/service_manager/service_manager_export.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 namespace content { 17 namespace content {
18 class MojoTest; 18 class MojoTest;
19 } 19 }
20 20
21 namespace mojo { 21 namespace mojo {
22 22
23 class ServiceLoader; 23 class ServiceLoader;
24 24
25 // Interface class for testing/debugging only.
DaveMoore 2014/04/04 21:06:46 This should either be a nested class within Servic
cpu_(ooo_6.6-7.5) 2014/04/04 23:42:45 Done.
26 class ServiceInterceptor {
27 public:
28 virtual ~ServiceInterceptor() {}
29 // Called when ServiceManager::Connect is called.
30 virtual ScopedMessagePipeHandle OnConnectToClient(
31 const GURL& url, ScopedMessagePipeHandle handle) = 0;
32 };
33
25 class MOJO_SERVICE_MANAGER_EXPORT ServiceManager { 34 class MOJO_SERVICE_MANAGER_EXPORT ServiceManager {
26 public: 35 public:
27 // API for testing. 36 // API for testing.
28 class MOJO_SERVICE_MANAGER_EXPORT TestAPI { 37 class MOJO_SERVICE_MANAGER_EXPORT TestAPI {
29 private: 38 private:
30 friend class ServiceManagerTest; 39 friend class ServiceManagerTest;
31 friend class content::MojoTest; 40 friend class content::MojoTest;
32 41
33 explicit TestAPI(ServiceManager* manager) : manager_(manager) {} 42 explicit TestAPI(ServiceManager* manager) : manager_(manager) {}
34 // Returns true if the shared instance has been created. 43 // Returns true if the shared instance has been created.
(...skipping 16 matching lines...) Expand all
51 // Sets the default Loader to be used if not overridden by 60 // Sets the default Loader to be used if not overridden by
52 // SetLoaderForURL() or SetLoaderForScheme(). 61 // SetLoaderForURL() or SetLoaderForScheme().
53 // Does not take ownership of |loader|. 62 // Does not take ownership of |loader|.
54 void set_default_loader(ServiceLoader* loader) { default_loader_ = loader; } 63 void set_default_loader(ServiceLoader* loader) { default_loader_ = loader; }
55 // Sets a Loader to be used for a specific url. 64 // Sets a Loader to be used for a specific url.
56 // Does not take ownership of |loader|. 65 // Does not take ownership of |loader|.
57 void SetLoaderForURL(ServiceLoader* loader, const GURL& url); 66 void SetLoaderForURL(ServiceLoader* loader, const GURL& url);
58 // Sets a Loader to be used for a specific url scheme. 67 // Sets a Loader to be used for a specific url scheme.
59 // Does not take ownership of |loader|. 68 // Does not take ownership of |loader|.
60 void SetLoaderForScheme(ServiceLoader* loader, const std::string& scheme); 69 void SetLoaderForScheme(ServiceLoader* loader, const std::string& scheme);
70 // Allows to interpose a debugger to service connections.
71 void SetInterceptor(ServiceInterceptor* interceptor);
61 72
62 private: 73 private:
63 class ServiceFactory; 74 class ServiceFactory;
64 typedef std::map<std::string, ServiceLoader*> SchemeToLoaderMap; 75 typedef std::map<std::string, ServiceLoader*> SchemeToLoaderMap;
65 typedef std::map<GURL, ServiceLoader*> URLToLoaderMap; 76 typedef std::map<GURL, ServiceLoader*> URLToLoaderMap;
66 typedef std::map<GURL, ServiceFactory*> URLToServiceFactoryMap; 77 typedef std::map<GURL, ServiceFactory*> URLToServiceFactoryMap;
67 78
68 // Returns the Loader to use for a url (using default if not overridden.) 79 // Returns the Loader to use for a url (using default if not overridden.)
69 // The preference is to use a loader that's been specified for an url first, 80 // The preference is to use a loader that's been specified for an url first,
70 // then one that's been specified for a scheme, then the default. 81 // then one that's been specified for a scheme, then the default.
71 ServiceLoader* GetLoaderForURL(const GURL& url); 82 ServiceLoader* GetLoaderForURL(const GURL& url);
72 83
73 // Removes a ServiceFactory when it no longer has any connections. 84 // Removes a ServiceFactory when it no longer has any connections.
74 void OnServiceFactoryError(ServiceFactory* service_factory); 85 void OnServiceFactoryError(ServiceFactory* service_factory);
75 86
76 // Loader management. 87 // Loader management.
77 URLToLoaderMap url_to_loader_; 88 URLToLoaderMap url_to_loader_;
78 SchemeToLoaderMap scheme_to_loader_; 89 SchemeToLoaderMap scheme_to_loader_;
79 ServiceLoader* default_loader_; 90 ServiceLoader* default_loader_;
91 ServiceInterceptor* interceptor_;
80 92
81 URLToServiceFactoryMap url_to_service_factory_; 93 URLToServiceFactoryMap url_to_service_factory_;
82 DISALLOW_COPY_AND_ASSIGN(ServiceManager); 94 DISALLOW_COPY_AND_ASSIGN(ServiceManager);
83 }; 95 };
84 96
85 } // namespace mojo 97 } // namespace mojo
86 98
87 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ 99 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698