| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/download/download_service_factory.h" | 5 #include "chrome/browser/download/download_service_factory.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/memory/ptr_util.h" |
| 8 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 9 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| 10 #include "base/task_scheduler/post_task.h" | 11 #include "base/task_scheduler/post_task.h" |
| 11 #include "base/task_scheduler/task_traits.h" | 12 #include "base/task_scheduler/task_traits.h" |
| 12 #include "chrome/browser/profiles/incognito_helpers.h" | 13 #include "chrome/browser/profiles/incognito_helpers.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
| 16 #include "components/download/public/clients.h" |
| 15 #include "components/download/public/download_service.h" | 17 #include "components/download/public/download_service.h" |
| 16 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 18 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 17 #include "content/public/browser/browser_context.h" | 19 #include "content/public/browser/browser_context.h" |
| 18 | 20 |
| 19 // static | 21 // static |
| 20 DownloadServiceFactory* DownloadServiceFactory::GetInstance() { | 22 DownloadServiceFactory* DownloadServiceFactory::GetInstance() { |
| 21 return base::Singleton<DownloadServiceFactory>::get(); | 23 return base::Singleton<DownloadServiceFactory>::get(); |
| 22 } | 24 } |
| 23 | 25 |
| 24 // static | 26 // static |
| (...skipping 17 matching lines...) Expand all Loading... |
| 42 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 44 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
| 43 base::CreateSequencedTaskRunnerWithTraits( | 45 base::CreateSequencedTaskRunnerWithTraits( |
| 44 {base::MayBlock(), base::TaskPriority::BACKGROUND}); | 46 {base::MayBlock(), base::TaskPriority::BACKGROUND}); |
| 45 | 47 |
| 46 base::FilePath storage_dir; | 48 base::FilePath storage_dir; |
| 47 if (!profile->IsOffTheRecord() && !profile->GetPath().empty()) { | 49 if (!profile->IsOffTheRecord() && !profile->GetPath().empty()) { |
| 48 storage_dir = | 50 storage_dir = |
| 49 profile->GetPath().Append(chrome::kDownloadServiceStorageDirname); | 51 profile->GetPath().Append(chrome::kDownloadServiceStorageDirname); |
| 50 } | 52 } |
| 51 | 53 |
| 52 download::DownloadService* service = | 54 download::DownloadService* service = download::DownloadService::Create( |
| 53 download::DownloadService::Create(storage_dir, background_task_runner); | 55 base::MakeUnique<download::DownloadClientMap>(), storage_dir, |
| 56 background_task_runner); |
| 54 | 57 |
| 55 // TODO(dtrainor): Register all clients here. | 58 // TODO(dtrainor): Register all clients here. |
| 56 return service; | 59 return service; |
| 57 } | 60 } |
| 58 | 61 |
| 59 content::BrowserContext* DownloadServiceFactory::GetBrowserContextToUse( | 62 content::BrowserContext* DownloadServiceFactory::GetBrowserContextToUse( |
| 60 content::BrowserContext* context) const { | 63 content::BrowserContext* context) const { |
| 61 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | 64 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| 62 } | 65 } |
| OLD | NEW |