OLD | NEW |
---|---|
(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 EXTENSIONS_TEST_SERVICE_REGISTRATION_MANAGER_TEST_API_H_ | |
6 #define EXTENSIONS_TEST_SERVICE_REGISTRATION_MANAGER_TEST_API_H_ | |
7 | |
8 #include "extensions/browser/service_registration_manager.h" | |
9 | |
10 #include <map> | |
11 #include <string> | |
12 | |
13 namespace extensions { | |
14 namespace internal { | |
15 | |
16 class TestServiceRegistrationManager : public ServiceRegistrationManager { | |
17 public: | |
18 TestServiceRegistrationManager(); | |
19 ~TestServiceRegistrationManager(); | |
20 | |
21 // Overrides an existing service factory with |factory| for testing. This | |
22 // does not alter the permission checks used to determine whether a service | |
23 // is available. | |
24 template <typename Interface> | |
25 void OverrideServiceFactoryForTest( | |
26 const base::Callback<void(mojo::InterfaceRequest<Interface>)>& factory) { | |
27 bool inserted = | |
28 test_factories_.insert(std::make_pair( | |
29 Interface::Name_, | |
30 linked_ptr<internal::ServiceFactoryBase>( | |
31 new internal::ServiceFactory<Interface>( | |
32 factory)))).second; | |
raymes
2014/10/24 00:09:30
Please break this up a bit to reduce the indenting
Sam McNally
2014/10/24 03:55:56
Done.
| |
33 DCHECK(inserted); | |
34 } | |
35 | |
36 virtual void AddServiceToServiceRegistry( | |
37 content::ServiceRegistry* service_registry, | |
38 ServiceFactoryBase* service_factory) override; | |
39 | |
40 private: | |
41 std::map<std::string, linked_ptr<ServiceFactoryBase>> test_factories_; | |
42 | |
43 ServiceRegistrationManager* service_registration_manager_; | |
44 | |
45 DISALLOW_COPY_AND_ASSIGN(TestServiceRegistrationManager); | |
46 }; | |
47 | |
48 } // namespace internal | |
49 | |
50 class ServiceRegistrationManagerTestApi { | |
raymes
2014/10/24 00:09:30
Why not just expose TestServiceRegistrationManager
Sam McNally
2014/10/24 03:55:56
ServiceRegistrationManager isn't really part of th
raymes
2014/10/27 00:11:46
As discussed, let's get rid of this class and just
Sam McNally
2014/10/27 06:56:25
Done.
| |
51 public: | |
52 ServiceRegistrationManagerTestApi(); | |
53 ~ServiceRegistrationManagerTestApi(); | |
54 | |
55 // Overrides an existing service factory with |factory| for testing. This | |
56 // does not alter the permission checks used to determine whether a service | |
57 // is available. | |
58 template <typename Interface> | |
59 void OverrideServiceFactoryForTest( | |
60 const base::Callback<void(mojo::InterfaceRequest<Interface>)>& factory) { | |
61 service_registration_manager_.OverrideServiceFactoryForTest(factory); | |
62 } | |
63 | |
64 private: | |
65 internal::TestServiceRegistrationManager service_registration_manager_; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(ServiceRegistrationManagerTestApi); | |
68 }; | |
69 | |
70 } // namespace extensions | |
71 | |
72 #endif // EXTENSIONS_TEST_SERVICE_REGISTRATION_MANAGER_TEST_API_H_ | |
OLD | NEW |