OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_PROFILES_PROFILE_DEPENDENCY_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_DEPENDENCY_MANAGER_H_ |
6 #define CHROME_BROWSER_PROFILES_PROFILE_DEPENDENCY_MANAGER_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_DEPENDENCY_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 public: | 24 public: |
25 // Adds/Removes a component from our list of live components. Removing will | 25 // Adds/Removes a component from our list of live components. Removing will |
26 // also remove live dependency links. | 26 // also remove live dependency links. |
27 void AddComponent(ProfileKeyedServiceFactory* component); | 27 void AddComponent(ProfileKeyedServiceFactory* component); |
28 void RemoveComponent(ProfileKeyedServiceFactory* component); | 28 void RemoveComponent(ProfileKeyedServiceFactory* component); |
29 | 29 |
30 // Adds a dependency between two factories. | 30 // Adds a dependency between two factories. |
31 void AddEdge(ProfileKeyedServiceFactory* depended, | 31 void AddEdge(ProfileKeyedServiceFactory* depended, |
32 ProfileKeyedServiceFactory* dependee); | 32 ProfileKeyedServiceFactory* dependee); |
33 | 33 |
| 34 // Called by each Profile to alert us of its creation. Several services want |
| 35 // to be started when a profile is created. Testing configuration is also |
| 36 // done at this time. (If you want your ProfileKeyedService to be started |
| 37 // with the Profile, override ProfileKeyedServiceFactory:: |
| 38 // ServiceIsCreatedWithProfile() to return true.) |
| 39 void CreateProfileServices(Profile* profile, bool is_testing_profile); |
| 40 |
34 // Called by each Profile to alert us that we should destroy services | 41 // Called by each Profile to alert us that we should destroy services |
35 // associated with it. | 42 // associated with it. |
36 // | 43 // |
37 // Why not use the existing PROFILE_DESTROYED notification? | 44 // Why not use the existing PROFILE_DESTROYED notification? |
38 // | 45 // |
39 // - Because we need to do everything here after the application has handled | 46 // - Because we need to do everything here after the application has handled |
40 // being notified about PROFILE_DESTROYED. | 47 // being notified about PROFILE_DESTROYED. |
41 // - Because this class is a singleton and Singletons can't rely on | 48 // - Because this class is a singleton and Singletons can't rely on |
42 // NotificationService in unit tests because NotificationService is | 49 // NotificationService in unit tests because NotificationService is |
43 // replaced in many tests. | 50 // replaced in many tests. |
44 void DestroyProfileServices(Profile* profile); | 51 void DestroyProfileServices(Profile* profile); |
45 | 52 |
46 #ifndef NDEBUG | 53 #ifndef NDEBUG |
47 // Unmark |profile| as dead. This exists because of unit tests, which will | |
48 // often have similar stack structures. 0xWhatever might be created, go out | |
49 // of scope, and then a new Profile object might be created at 0xWhatever. | |
50 void ProfileNowExists(Profile* profile); | |
51 | |
52 // Debugging assertion called as part of GetServiceForProfile in debug | 54 // Debugging assertion called as part of GetServiceForProfile in debug |
53 // mode. This will NOTREACHED() whenever the user is trying to access a stale | 55 // mode. This will NOTREACHED() whenever the user is trying to access a stale |
54 // Profile*. | 56 // Profile*. |
55 void AssertProfileWasntDestroyed(Profile* profile); | 57 void AssertProfileWasntDestroyed(Profile* profile); |
56 #endif | 58 #endif |
57 | 59 |
58 static ProfileDependencyManager* GetInstance(); | 60 static ProfileDependencyManager* GetInstance(); |
59 | 61 |
60 private: | 62 private: |
61 friend class ProfileDependencyManagerUnittests; | 63 friend class ProfileDependencyManagerUnittests; |
(...skipping 18 matching lines...) Expand all Loading... |
80 #ifndef NDEBUG | 82 #ifndef NDEBUG |
81 // A list of profile objects that have gone through the Shutdown() | 83 // A list of profile objects that have gone through the Shutdown() |
82 // phase. These pointers are most likely invalid, but we keep track of their | 84 // phase. These pointers are most likely invalid, but we keep track of their |
83 // locations in memory so we can nicely assert if we're asked to do anything | 85 // locations in memory so we can nicely assert if we're asked to do anything |
84 // with them. | 86 // with them. |
85 std::set<Profile*> dead_profile_pointers_; | 87 std::set<Profile*> dead_profile_pointers_; |
86 #endif | 88 #endif |
87 }; | 89 }; |
88 | 90 |
89 #endif // CHROME_BROWSER_PROFILES_PROFILE_DEPENDENCY_MANAGER_H_ | 91 #endif // CHROME_BROWSER_PROFILES_PROFILE_DEPENDENCY_MANAGER_H_ |
OLD | NEW |