Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_model_factory.cc

Issue 2185973003: [Offline Pages] Delete associated page along with bookmark. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moving to c++. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/sequenced_task_runner.h" 11 #include "base/sequenced_task_runner.h"
12 #include "chrome/browser/bookmarks/bookmark_model_factory.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"
15 #include "components/keyed_service/content/browser_context_dependency_manager.h" 16 #include "components/keyed_service/content/browser_context_dependency_manager.h"
16 #include "components/offline_pages/offline_page_metadata_store_sql.h" 17 #include "components/offline_pages/offline_page_metadata_store_sql.h"
17 #include "components/offline_pages/offline_page_model_impl.h" 18 #include "components/offline_pages/offline_page_model_impl.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 20
20 namespace offline_pages { 21 namespace offline_pages {
21 22
22 OfflinePageModelFactory::OfflinePageModelFactory() 23 OfflinePageModelFactory::OfflinePageModelFactory()
23 : BrowserContextKeyedServiceFactory( 24 : BrowserContextKeyedServiceFactory(
24 "OfflinePageModel", 25 "OfflinePageModel",
25 BrowserContextDependencyManager::GetInstance()) { 26 BrowserContextDependencyManager::GetInstance()) {
27 DependsOn(BookmarkModelFactory::GetInstance());
Dmitry Titov 2016/08/01 23:46:58 Hmm, I wonder if it's a right direction of the dep
26 } 28 }
27 29
28 // static 30 // static
29 OfflinePageModelFactory* OfflinePageModelFactory::GetInstance() { 31 OfflinePageModelFactory* OfflinePageModelFactory::GetInstance() {
30 return base::Singleton<OfflinePageModelFactory>::get(); 32 return base::Singleton<OfflinePageModelFactory>::get();
31 } 33 }
32 34
33 // static 35 // static
34 OfflinePageModel* OfflinePageModelFactory::GetForBrowserContext( 36 OfflinePageModel* OfflinePageModelFactory::GetForBrowserContext(
35 content::BrowserContext* context) { 37 content::BrowserContext* context) {
36 return static_cast<OfflinePageModelImpl*>( 38 return static_cast<OfflinePageModelImpl*>(
37 GetInstance()->GetServiceForBrowserContext(context, true)); 39 GetInstance()->GetServiceForBrowserContext(context, true));
38 } 40 }
39 41
40 KeyedService* OfflinePageModelFactory::BuildServiceInstanceFor( 42 KeyedService* OfflinePageModelFactory::BuildServiceInstanceFor(
41 content::BrowserContext* context) const { 43 content::BrowserContext* context) const {
42 Profile* profile = Profile::FromBrowserContext(context); 44 Profile* profile = Profile::FromBrowserContext(context);
43 scoped_refptr<base::SequencedTaskRunner> background_task_runner = 45 scoped_refptr<base::SequencedTaskRunner> background_task_runner =
44 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( 46 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
45 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); 47 content::BrowserThread::GetBlockingPool()->GetSequenceToken());
46 48
47 base::FilePath store_path = 49 base::FilePath store_path =
48 profile->GetPath().Append(chrome::kOfflinePageMetadataDirname); 50 profile->GetPath().Append(chrome::kOfflinePageMetadataDirname);
49 std::unique_ptr<OfflinePageMetadataStore> metadata_store( 51 std::unique_ptr<OfflinePageMetadataStore> metadata_store(
50 new OfflinePageMetadataStoreSQL(background_task_runner, store_path)); 52 new OfflinePageMetadataStoreSQL(background_task_runner, store_path));
51 53
52 base::FilePath archives_dir = 54 base::FilePath archives_dir =
53 profile->GetPath().Append(chrome::kOfflinePageArchivesDirname); 55 profile->GetPath().Append(chrome::kOfflinePageArchivesDirname);
54 56
55 return new OfflinePageModelImpl(std::move(metadata_store), archives_dir, 57 OfflinePageModelImpl* model = new OfflinePageModelImpl(
56 background_task_runner); 58 std::move(metadata_store), archives_dir, background_task_runner);
59 BookmarkModelFactory::GetForProfile(profile)->AddObserver(model);
60 return model;
57 } 61 }
58 62
59 } // namespace offline_pages 63 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | components/offline_pages/DEPS » ('j') | components/offline_pages/offline_page_model_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698