OLD | NEW |
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 "mojo/public/shell/shell.mojom.h" | 13 #include "mojo/public/shell/shell.mojom.h" |
| 14 #include "mojo/service_manager/service_manager_export.h" |
13 #include "url/gurl.h" | 15 #include "url/gurl.h" |
14 | 16 |
| 17 namespace content { |
| 18 class MojoTest; |
| 19 } |
| 20 |
15 namespace mojo { | 21 namespace mojo { |
16 | 22 |
17 class ServiceLoader; | 23 class ServiceLoader; |
18 | 24 |
19 class ServiceManager { | 25 class MOJO_SERVICE_MANAGER_EXPORT ServiceManager { |
20 public: | 26 public: |
21 // API for testing. | 27 // API for testing. |
22 class TestAPI { | 28 class MOJO_SERVICE_MANAGER_EXPORT TestAPI { |
23 private: | 29 private: |
24 friend class ServiceManagerTest; | 30 friend class ServiceManagerTest; |
| 31 friend class content::MojoTest; |
| 32 |
25 explicit TestAPI(ServiceManager* manager) : manager_(manager) {} | 33 explicit TestAPI(ServiceManager* manager) : manager_(manager) {} |
| 34 // Returns true if the shared instance has been created. |
| 35 MOJO_SERVICE_MANAGER_EXPORT static bool HasCreatedInstance(); |
26 // Returns true if there is a ServiceFactory for this URL. | 36 // Returns true if there is a ServiceFactory for this URL. |
27 bool HasFactoryForURL(const GURL& url) const; | 37 bool HasFactoryForURL(const GURL& url) const; |
28 | 38 |
29 ServiceManager* manager_; | 39 ServiceManager* manager_; |
30 }; | 40 }; |
31 | 41 |
32 ServiceManager(); | 42 ServiceManager(); |
33 ~ServiceManager(); | 43 ~ServiceManager(); |
34 | 44 |
35 // Returns a shared instance, creating it if necessary. | 45 // Returns a shared instance, creating it if necessary. |
(...skipping 20 matching lines...) Expand all Loading... |
56 typedef std::map<GURL, ServiceFactory*> ServiceFactoryMap; | 66 typedef std::map<GURL, ServiceFactory*> ServiceFactoryMap; |
57 ServiceFactoryMap url_to_service_factory_; | 67 ServiceFactoryMap url_to_service_factory_; |
58 typedef std::map<GURL, ServiceLoader*> LoaderMap; | 68 typedef std::map<GURL, ServiceLoader*> LoaderMap; |
59 LoaderMap url_to_loader_; | 69 LoaderMap url_to_loader_; |
60 DISALLOW_COPY_AND_ASSIGN(ServiceManager); | 70 DISALLOW_COPY_AND_ASSIGN(ServiceManager); |
61 }; | 71 }; |
62 | 72 |
63 } // namespace mojo | 73 } // namespace mojo |
64 | 74 |
65 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ | 75 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ |
OLD | NEW |