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

Side by Side Diff: components/offline_pages/offline_page_model.cc

Issue 1965633002: [Offline Pages] Introducing StorageManagerClient interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplifying interface per suggestion. Created 4 years, 7 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 "components/offline_pages/offline_page_model.h" 5 #include "components/offline_pages/offline_page_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 OfflinePageModel::OfflinePageModel( 118 OfflinePageModel::OfflinePageModel(
119 std::unique_ptr<OfflinePageMetadataStore> store, 119 std::unique_ptr<OfflinePageMetadataStore> store,
120 const base::FilePath& archives_dir, 120 const base::FilePath& archives_dir,
121 const scoped_refptr<base::SequencedTaskRunner>& task_runner) 121 const scoped_refptr<base::SequencedTaskRunner>& task_runner)
122 : store_(std::move(store)), 122 : store_(std::move(store)),
123 archives_dir_(archives_dir), 123 archives_dir_(archives_dir),
124 is_loaded_(false), 124 is_loaded_(false),
125 task_runner_(task_runner), 125 task_runner_(task_runner),
126 policy_controller_(new ClientPolicyController()), 126 policy_controller_(new ClientPolicyController()),
127 storage_manager_(new OfflinePageStorageManager(this)),
128 weak_ptr_factory_(this) { 127 weak_ptr_factory_(this) {
129 task_runner_->PostTaskAndReply( 128 task_runner_->PostTaskAndReply(
130 FROM_HERE, base::Bind(EnsureArchivesDirCreated, archives_dir_), 129 FROM_HERE, base::Bind(EnsureArchivesDirCreated, archives_dir_),
131 base::Bind(&OfflinePageModel::OnEnsureArchivesDirCreatedDone, 130 base::Bind(&OfflinePageModel::OnEnsureArchivesDirCreatedDone,
132 weak_ptr_factory_.GetWeakPtr(), base::TimeTicks::Now())); 131 weak_ptr_factory_.GetWeakPtr(), base::TimeTicks::Now()));
133 } 132 }
134 133
135 OfflinePageModel::~OfflinePageModel() { 134 OfflinePageModel::~OfflinePageModel() {
136 } 135 }
137 136
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 is_loaded_ = true; 629 is_loaded_ = true;
631 630
632 // TODO(jianli): rebuild the store upon failure. 631 // TODO(jianli): rebuild the store upon failure.
633 632
634 if (load_status == OfflinePageMetadataStore::LOAD_SUCCEEDED) 633 if (load_status == OfflinePageMetadataStore::LOAD_SUCCEEDED)
635 CacheLoadedData(offline_pages); 634 CacheLoadedData(offline_pages);
636 635
637 UMA_HISTOGRAM_TIMES("OfflinePages.Model.ConstructionToLoadedEventTime", 636 UMA_HISTOGRAM_TIMES("OfflinePages.Model.ConstructionToLoadedEventTime",
638 base::TimeTicks::Now() - start_time); 637 base::TimeTicks::Now() - start_time);
639 638
639 // Create Storage Manager.
640 storage_manager_.reset(
641 new OfflinePageStorageManager(this, GetPolicyController()));
642
640 // Run all the delayed tasks. 643 // Run all the delayed tasks.
641 for (const auto& delayed_task : delayed_tasks_) 644 for (const auto& delayed_task : delayed_tasks_)
642 delayed_task.Run(); 645 delayed_task.Run();
643 delayed_tasks_.clear(); 646 delayed_tasks_.clear();
644 647
645 FOR_EACH_OBSERVER(Observer, observers_, OfflinePageModelLoaded(this)); 648 FOR_EACH_OBSERVER(Observer, observers_, OfflinePageModelLoaded(this));
646 649
647 CheckForExternalFileDeletion(); 650 CheckForExternalFileDeletion();
648 } 651 }
649 652
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 void OfflinePageModel::RunWhenLoaded(const base::Closure& task) { 834 void OfflinePageModel::RunWhenLoaded(const base::Closure& task) {
832 if (!is_loaded_) { 835 if (!is_loaded_) {
833 delayed_tasks_.push_back(task); 836 delayed_tasks_.push_back(task);
834 return; 837 return;
835 } 838 }
836 839
837 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); 840 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task);
838 } 841 }
839 842
840 } // namespace offline_pages 843 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_model.h ('k') | components/offline_pages/offline_page_storage_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698