| Index: chrome/browser/profiles/profile_dependency_manager.h
|
| diff --git a/chrome/browser/profiles/profile_dependency_manager.h b/chrome/browser/profiles/profile_dependency_manager.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..94349e3da9675e92a1877290174fa081065416e5
|
| --- /dev/null
|
| +++ b/chrome/browser/profiles/profile_dependency_manager.h
|
| @@ -0,0 +1,58 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CHROME_BROWSER_PROFILES_PROFILE_DEPENDENCY_MANAGER_H_
|
| +#define CHROME_BROWSER_PROFILES_PROFILE_DEPENDENCY_MANAGER_H_
|
| +
|
| +#include <map>
|
| +#include <vector>
|
| +
|
| +#include "base/memory/singleton.h"
|
| +#include "content/common/notification_observer.h"
|
| +#include "content/common/notification_registrar.h"
|
| +
|
| +class ProfileKeyedServiceFactory;
|
| +
|
| +// A singleton that listens for profile destruction notifications and
|
| +// rebroadcasts them to each ProfileKeyedServiceFactory in a safe order based
|
| +// on the stated dependencies by each service.
|
| +class ProfileDependencyManager : public NotificationObserver {
|
| + public:
|
| + void AddComponent(ProfileKeyedServiceFactory* component);
|
| + void RemoveComponent(ProfileKeyedServiceFactory* component);
|
| +
|
| + void AddEdge(ProfileKeyedServiceFactory* depended,
|
| + ProfileKeyedServiceFactory* dependee);
|
| +
|
| + static ProfileDependencyManager* GetInstance();
|
| +
|
| + private:
|
| + friend class ProfileDependencyManagerUnittests;
|
| + friend struct DefaultSingletonTraits<ProfileDependencyManager>;
|
| +
|
| + typedef std::multimap<ProfileKeyedServiceFactory*,
|
| + ProfileKeyedServiceFactory*> EdgeMap;
|
| +
|
| + ProfileDependencyManager();
|
| + virtual ~ProfileDependencyManager();
|
| +
|
| + // Using the dependency graph defined in |edges_|, fills |destruction_order_|
|
| + // so that Observe() can notify each ProfileKeyedServiceFactory in order.
|
| + void BuildDestructionOrder();
|
| +
|
| + // NotificationObserver:
|
| + virtual void Observe(NotificationType type,
|
| + const NotificationSource& source,
|
| + const NotificationDetails& details);
|
| +
|
| + std::vector<ProfileKeyedServiceFactory*> all_components_;
|
| +
|
| + EdgeMap edges_;
|
| +
|
| + std::vector<ProfileKeyedServiceFactory*> destruction_order_;
|
| +
|
| + NotificationRegistrar registrar_;
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_PROFILES_PROFILE_DEPENDENCY_MANAGER_H_
|
|
|