| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/offline_pages/offline_page_model_factory.h" | 5 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
| 13 #include "chrome/browser/profiles/incognito_helpers.h" | 13 #include "chrome/browser/profiles/incognito_helpers.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
| 16 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 16 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 17 #include "components/offline_pages/offline_page_client_policy.h" |
| 17 #include "components/offline_pages/offline_page_metadata_store_impl.h" | 18 #include "components/offline_pages/offline_page_metadata_store_impl.h" |
| 18 #include "components/offline_pages/offline_page_model.h" | 19 #include "components/offline_pages/offline_page_model.h" |
| 19 #include "components/offline_pages/proto/offline_pages.pb.h" | 20 #include "components/offline_pages/proto/offline_pages.pb.h" |
| 20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 21 | 22 |
| 23 using LifetimeType = offline_pages::LifetimePolicy::LifetimeType; |
| 24 |
| 22 namespace offline_pages { | 25 namespace offline_pages { |
| 23 | 26 |
| 24 OfflinePageModelFactory::OfflinePageModelFactory() | 27 OfflinePageModelFactory::OfflinePageModelFactory() |
| 25 : BrowserContextKeyedServiceFactory( | 28 : BrowserContextKeyedServiceFactory( |
| 26 "OfflinePageModel", | 29 "OfflinePageModel", |
| 27 BrowserContextDependencyManager::GetInstance()) { | 30 BrowserContextDependencyManager::GetInstance()) { |
| 28 } | 31 } |
| 29 | 32 |
| 30 // static | 33 // static |
| 31 OfflinePageModelFactory* OfflinePageModelFactory::GetInstance() { | 34 OfflinePageModelFactory* OfflinePageModelFactory::GetInstance() { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 44 Profile* profile = Profile::FromBrowserContext(context); | 47 Profile* profile = Profile::FromBrowserContext(context); |
| 45 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 48 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
| 46 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 49 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
| 47 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); | 50 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); |
| 48 | 51 |
| 49 base::FilePath store_path = | 52 base::FilePath store_path = |
| 50 profile->GetPath().Append(chrome::kOfflinePageMetadataDirname); | 53 profile->GetPath().Append(chrome::kOfflinePageMetadataDirname); |
| 51 std::unique_ptr<OfflinePageMetadataStoreImpl> metadata_store( | 54 std::unique_ptr<OfflinePageMetadataStoreImpl> metadata_store( |
| 52 new OfflinePageMetadataStoreImpl(background_task_runner, store_path)); | 55 new OfflinePageMetadataStoreImpl(background_task_runner, store_path)); |
| 53 | 56 |
| 54 base::FilePath archives_dir = | 57 base::FilePath archive_persistent = |
| 55 profile->GetPath().Append(chrome::kOfflinePageArchviesDirname); | 58 profile->GetPath().Append(chrome::kOfflinePageArchivesDirname); |
| 56 | 59 |
| 57 return new OfflinePageModel(std::move(metadata_store), archives_dir, | 60 OfflinePageModel::ArchiveDirs archive_dirs; |
| 61 archive_dirs.insert( |
| 62 std::make_pair(LifetimeType::TEMPORARY, archive_persistent)); |
| 63 archive_dirs.insert( |
| 64 std::make_pair(LifetimeType::PERSISTENT, archive_persistent)); |
| 65 |
| 66 return new OfflinePageModel(std::move(metadata_store), archive_dirs, |
| 58 background_task_runner); | 67 background_task_runner); |
| 59 } | 68 } |
| 60 | 69 |
| 61 content::BrowserContext* OfflinePageModelFactory::GetBrowserContextToUse( | 70 content::BrowserContext* OfflinePageModelFactory::GetBrowserContextToUse( |
| 62 content::BrowserContext* context) const { | 71 content::BrowserContext* context) const { |
| 63 return chrome::GetBrowserContextRedirectedInIncognito(context); | 72 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 64 } | 73 } |
| 65 | 74 |
| 66 } // namespace offline_pages | 75 } // namespace offline_pages |
| 67 | 76 |
| OLD | NEW |