| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/android/blimp/blimp_client_context_factory.h" | 5 #include "chrome/browser/android/blimp/blimp_client_context_factory.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "base/supports_user_data.h" | 8 #include "base/supports_user_data.h" |
| 9 #include "blimp/client/public/blimp_client_context.h" | 9 #include "blimp/client/public/blimp_client_context.h" |
| 10 #include "chrome/browser/android/blimp/chrome_compositor_dependencies.h" |
| 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 11 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
| 12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "ui/android/context_provider_factory.h" |
| 13 | 15 |
| 14 // static | 16 // static |
| 15 BlimpClientContextFactory* BlimpClientContextFactory::GetInstance() { | 17 BlimpClientContextFactory* BlimpClientContextFactory::GetInstance() { |
| 16 return base::Singleton<BlimpClientContextFactory>::get(); | 18 return base::Singleton<BlimpClientContextFactory>::get(); |
| 17 } | 19 } |
| 18 | 20 |
| 19 // static | 21 // static |
| 20 blimp::client::BlimpClientContext* | 22 blimp::client::BlimpClientContext* |
| 21 BlimpClientContextFactory::GetForBrowserContext( | 23 BlimpClientContextFactory::GetForBrowserContext( |
| 22 content::BrowserContext* context) { | 24 content::BrowserContext* context) { |
| 23 DCHECK(!context->IsOffTheRecord()); | 25 DCHECK(!context->IsOffTheRecord()); |
| 24 return static_cast<blimp::client::BlimpClientContext*>( | 26 return static_cast<blimp::client::BlimpClientContext*>( |
| 25 GetInstance()->GetServiceForBrowserContext(context, true)); | 27 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 26 } | 28 } |
| 27 | 29 |
| 28 BlimpClientContextFactory::BlimpClientContextFactory() | 30 BlimpClientContextFactory::BlimpClientContextFactory() |
| 29 : BrowserContextKeyedServiceFactory( | 31 : BrowserContextKeyedServiceFactory( |
| 30 "blimp::client::BlimpClientContext", | 32 "blimp::client::BlimpClientContext", |
| 31 BrowserContextDependencyManager::GetInstance()) {} | 33 BrowserContextDependencyManager::GetInstance()) {} |
| 32 | 34 |
| 33 BlimpClientContextFactory::~BlimpClientContextFactory() {} | 35 BlimpClientContextFactory::~BlimpClientContextFactory() {} |
| 34 | 36 |
| 35 KeyedService* BlimpClientContextFactory::BuildServiceInstanceFor( | 37 KeyedService* BlimpClientContextFactory::BuildServiceInstanceFor( |
| 36 content::BrowserContext* context) const { | 38 content::BrowserContext* context) const { |
| 37 return blimp::client::BlimpClientContext::Create( | 39 return blimp::client::BlimpClientContext::Create( |
| 38 content::BrowserThread::GetTaskRunnerForThread( | 40 content::BrowserThread::GetTaskRunnerForThread( |
| 39 content::BrowserThread::IO), | 41 content::BrowserThread::IO), |
| 40 content::BrowserThread::GetTaskRunnerForThread( | 42 content::BrowserThread::GetTaskRunnerForThread( |
| 41 content::BrowserThread::FILE)); | 43 content::BrowserThread::FILE), |
| 44 base::MakeUnique<ChromeCompositorDependencies>( |
| 45 ui::ContextProviderFactory::GetInstance())); |
| 42 } | 46 } |
| 43 | 47 |
| 44 content::BrowserContext* BlimpClientContextFactory::GetBrowserContextToUse( | 48 content::BrowserContext* BlimpClientContextFactory::GetBrowserContextToUse( |
| 45 content::BrowserContext* context) const { | 49 content::BrowserContext* context) const { |
| 46 return context; | 50 return context; |
| 47 } | 51 } |
| OLD | NEW |