16d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
26d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
36d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// found in the LICENSE file.
46d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h"
56d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
66d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h"
76d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "chrome/browser/profiles/profile.h"
86d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "components/keyed_service/content/browser_context_dependency_manager.h"
96d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
106d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)/// Factory
116d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)BitmapFetcherService* BitmapFetcherServiceFactory::GetForBrowserContext(
126d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    content::BrowserContext* profile) {
136d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  return static_cast<BitmapFetcherService*>(
146d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)      GetInstance()->GetServiceForBrowserContext(profile, true));
156d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)}
166d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
176d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// static
186d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)BitmapFetcherServiceFactory* BitmapFetcherServiceFactory::GetInstance() {
196d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  return Singleton<BitmapFetcherServiceFactory>::get();
206d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)}
216d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
226d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)BitmapFetcherServiceFactory::BitmapFetcherServiceFactory()
236d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    : BrowserContextKeyedServiceFactory(
246d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)          "BitmapFetcherService",
256d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)          BrowserContextDependencyManager::GetInstance()) {
266d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)}
276d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
286d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)BitmapFetcherServiceFactory::~BitmapFetcherServiceFactory() {
296d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)}
306d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
316d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)KeyedService* BitmapFetcherServiceFactory::BuildServiceInstanceFor(
326d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    content::BrowserContext* context) const {
336d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  Profile* profile = static_cast<Profile*>(context);
346d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  DCHECK(!profile->IsOffTheRecord());
356d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  return new BitmapFetcherService(profile);
366d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)}
37