image_loader_factory.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #ifndef EXTENSIONS_BROWSER_IMAGE_LOADER_FACTORY_H_
  5. #define EXTENSIONS_BROWSER_IMAGE_LOADER_FACTORY_H_
  6. #include "base/memory/singleton.h"
  7. #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
  8. namespace content {
  9. class BrowserContext;
  10. }
  11. namespace extensions {
  12. class ImageLoader;
  13. // Singleton that owns all ImageLoaders and associates them with
  14. // BrowserContexts. Listens for the BrowserContext's destruction notification
  15. // and cleans up the associated ImageLoader. Uses the original BrowserContext
  16. // for incognito contexts.
  17. class ImageLoaderFactory : public BrowserContextKeyedServiceFactory {
  18. public:
  19. static ImageLoader* GetForBrowserContext(content::BrowserContext* context);
  20. static ImageLoaderFactory* GetInstance();
  21. private:
  22. friend struct base::DefaultSingletonTraits<ImageLoaderFactory>;
  23. ImageLoaderFactory();
  24. ~ImageLoaderFactory() override;
  25. // BrowserContextKeyedServiceFactory:
  26. KeyedService* BuildServiceInstanceFor(
  27. content::BrowserContext* context) const override;
  28. content::BrowserContext* GetBrowserContextToUse(
  29. content::BrowserContext* context) const override;
  30. };
  31. } // namespace extensions
  32. #endif // EXTENSIONS_BROWSER_IMAGE_LOADER_FACTORY_H_