Create a ProfileDependencyManager to order ProfileKeyedService destruction.
Since ProfileKeyedServices need to be able to specify complex graphs
representing their dependencies on other ProfileKeyedServices, add a simple
::DependsOn() method to explicitly state these dependencies and a singleton
manager in the background that does a topological sort to get a safe
destruction ordering.
This changes ThemeServiceFactory to use this new system, which also revealed a bunch of unsafe casting of Source<> pointers and NotificationCenter misuse between incompatible types. (Source<> uses void* underneath and therefore can't increment/decrement the pointer during casting.)
BUG=77155
TEST=compiles, new ProfileDependencyManagerUnittests.*
Review URL: http://codereview.chromium.org/6766004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80093 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 5a06b32..38f26c5 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1632,12 +1632,16 @@
'browser/profiles/off_the_record_profile_io_data.h',
'browser/profiles/profile.cc',
'browser/profiles/profile.h',
+ 'browser/profiles/profile_dependency_manager.cc',
+ 'browser/profiles/profile_dependency_manager.h',
'browser/profiles/profile_impl.cc',
'browser/profiles/profile_impl.h',
'browser/profiles/profile_impl_io_data.cc',
'browser/profiles/profile_impl_io_data.h',
'browser/profiles/profile_io_data.cc',
'browser/profiles/profile_io_data.h',
+ 'browser/profiles/profile_keyed_service_factory.cc',
+ 'browser/profiles/profile_keyed_service_factory.h',
'browser/profiles/profile_manager.cc',
'browser/profiles/profile_manager.h',
'browser/remoting/directory_add_request.cc',