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 "base/gtest_prod_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "mojo/public/interfaces/shell/shell.mojom.h" | 14 #include "mojo/public/interfaces/shell/shell.mojom.h" |
15 #include "mojo/service_manager/service_loader.h" | 15 #include "mojo/service_manager/service_loader.h" |
16 #include "mojo/service_manager/service_manager_export.h" | 16 #include "mojo/service_manager/service_manager_export.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
18 | 18 |
19 namespace content { | |
20 class MojoTest; | |
21 } | |
22 | |
23 namespace mojo { | 19 namespace mojo { |
24 | 20 |
25 class MOJO_SERVICE_MANAGER_EXPORT ServiceManager { | 21 class MOJO_SERVICE_MANAGER_EXPORT ServiceManager { |
26 public: | 22 public: |
27 // API for testing. | 23 // API for testing. |
28 class MOJO_SERVICE_MANAGER_EXPORT TestAPI { | 24 class MOJO_SERVICE_MANAGER_EXPORT TestAPI { |
29 private: | 25 public: |
30 friend class ServiceManagerTest; | 26 explicit TestAPI(ServiceManager* manager); |
31 friend class content::MojoTest; | 27 ~TestAPI(); |
32 | 28 |
33 explicit TestAPI(ServiceManager* manager) : manager_(manager) {} | 29 // Returns a handle to the shell. |
| 30 ScopedShellHandle GetShellHandle(); |
| 31 |
34 // Returns true if the shared instance has been created. | 32 // Returns true if the shared instance has been created. |
35 static bool HasCreatedInstance(); | 33 static bool HasCreatedInstance(); |
36 // Returns true if there is a ServiceFactory for this URL. | 34 // Returns true if there is a ServiceFactory for this URL. |
37 bool HasFactoryForURL(const GURL& url) const; | 35 bool HasFactoryForURL(const GURL& url) const; |
38 | 36 |
| 37 private: |
| 38 class TestShellConnection; |
| 39 |
39 ServiceManager* manager_; | 40 ServiceManager* manager_; |
| 41 |
| 42 scoped_ptr<TestShellConnection> shell_connection_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(TestAPI); |
40 }; | 45 }; |
41 | 46 |
42 // Interface class for debugging only. | 47 // Interface class for debugging only. |
43 class Interceptor { | 48 class Interceptor { |
44 public: | 49 public: |
45 virtual ~Interceptor() {} | 50 virtual ~Interceptor() {} |
46 // Called when ServiceManager::Connect is called. | 51 // Called when ServiceManager::Connect is called. |
47 virtual ScopedMessagePipeHandle OnConnectToClient( | 52 virtual ScopedMessagePipeHandle OnConnectToClient( |
48 const GURL& url, ScopedMessagePipeHandle handle) = 0; | 53 const GURL& url, ScopedMessagePipeHandle handle) = 0; |
49 }; | 54 }; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 scoped_ptr<ServiceLoader> default_loader_; | 95 scoped_ptr<ServiceLoader> default_loader_; |
91 Interceptor* interceptor_; | 96 Interceptor* interceptor_; |
92 | 97 |
93 URLToServiceFactoryMap url_to_service_factory_; | 98 URLToServiceFactoryMap url_to_service_factory_; |
94 DISALLOW_COPY_AND_ASSIGN(ServiceManager); | 99 DISALLOW_COPY_AND_ASSIGN(ServiceManager); |
95 }; | 100 }; |
96 | 101 |
97 } // namespace mojo | 102 } // namespace mojo |
98 | 103 |
99 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ | 104 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ |
OLD | NEW |