OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 |
| 5 #include "components/reporting/content/browser/reporting_service_factory.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "components/reporting/core/browser/reporting_service.h" |
| 9 #include "content/public/browser/browser_context.h" |
| 10 #include "content/public/browser/storage_partition.h" |
| 11 #include "content/public/common/origin_util.h" |
| 12 |
| 13 namespace reporting { |
| 14 |
| 15 // static |
| 16 ReportingService* ReportingServiceFactory::GetForBrowserContext( |
| 17 content::BrowserContext* context, |
| 18 bool create) { |
| 19 return static_cast<ReportingService*>( |
| 20 GetInstance()->GetServiceForBrowserContext(context, create)); |
| 21 } |
| 22 |
| 23 // static |
| 24 ReportingServiceFactory* ReportingServiceFactory::GetInstance() { |
| 25 return base::Singleton<ReportingServiceFactory>::get(); |
| 26 } |
| 27 |
| 28 ReportingServiceFactory::ReportingServiceFactory() |
| 29 : BrowserContextKeyedServiceFactory( |
| 30 "ReportingService", |
| 31 BrowserContextDependencyManager::GetInstance()) {} |
| 32 |
| 33 ReportingServiceFactory::~ReportingServiceFactory() {} |
| 34 |
| 35 KeyedService* ReportingServiceFactory::BuildServiceInstanceFor( |
| 36 content::BrowserContext* browser_context) const { |
| 37 scoped_refptr<net::URLRequestContextGetter> request_context = |
| 38 content::BrowserContext::GetDefaultStoragePartition(browser_context) |
| 39 ->GetURLRequestContext(); |
| 40 std::unique_ptr<ReportingService> service(ReportingService::Create( |
| 41 request_context, base::Bind(&content::IsOriginSecure))); |
| 42 return service.release(); |
| 43 } |
| 44 |
| 45 } // namespace reporting |
OLD | NEW |