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

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

Issue 1921563005: [Offline Pages] Remove obsolete synchronous API methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add todo Created 4 years, 8 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
« no previous file with comments | « components/offline_pages/offline_page_model.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 void OfflinePageModel::HasPages(const std::string& name_space, 273 void OfflinePageModel::HasPages(const std::string& name_space,
274 const HasPagesCallback& callback) { 274 const HasPagesCallback& callback) {
275 RunWhenLoaded(base::Bind(&OfflinePageModel::HasPagesAfterLoadDone, 275 RunWhenLoaded(base::Bind(&OfflinePageModel::HasPagesAfterLoadDone,
276 weak_ptr_factory_.GetWeakPtr(), name_space, 276 weak_ptr_factory_.GetWeakPtr(), name_space,
277 callback)); 277 callback));
278 } 278 }
279 279
280 void OfflinePageModel::HasPagesAfterLoadDone( 280 void OfflinePageModel::HasPagesAfterLoadDone(
281 const std::string& name_space, 281 const std::string& name_space,
282 const HasPagesCallback& callback) const { 282 const HasPagesCallback& callback) const {
283 callback.Run(MaybeHasPages(name_space)); 283 DCHECK(is_loaded_);
284 }
285 284
286 bool OfflinePageModel::MaybeHasPages(const std::string& name_space) const { 285 bool has_pages = false;
287 if (!is_loaded_)
288 return false;
289 286
290 for (const auto& id_page_pair : offline_pages_) { 287 for (const auto& id_page_pair : offline_pages_) {
291 if (id_page_pair.second.client_id.name_space == name_space) 288 if (id_page_pair.second.client_id.name_space == name_space) {
292 return true; 289 has_pages = true;
290 break;
291 }
293 } 292 }
294 293
295 return false; 294 callback.Run(has_pages);
296 } 295 }
297 296
298 void OfflinePageModel::GetAllPages(const GetAllPagesCallback& callback) { 297 void OfflinePageModel::GetAllPages(const GetAllPagesCallback& callback) {
299 if (!is_loaded_) { 298 if (!is_loaded_) {
300 delayed_tasks_.push_back( 299 delayed_tasks_.push_back(
301 base::Bind(&OfflinePageModel::GetAllPagesAfterLoadDone, 300 base::Bind(&OfflinePageModel::GetAllPagesAfterLoadDone,
302 weak_ptr_factory_.GetWeakPtr(), callback)); 301 weak_ptr_factory_.GetWeakPtr(), callback));
303 return; 302 return;
304 } 303 }
305 304
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 void OfflinePageModel::RunWhenLoaded(const base::Closure& task) { 697 void OfflinePageModel::RunWhenLoaded(const base::Closure& task) {
699 if (!is_loaded_) { 698 if (!is_loaded_) {
700 delayed_tasks_.push_back(task); 699 delayed_tasks_.push_back(task);
701 return; 700 return;
702 } 701 }
703 702
704 task_runner_->PostTask(FROM_HERE, task); 703 task_runner_->PostTask(FROM_HERE, task);
705 } 704 }
706 705
707 } // namespace offline_pages 706 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_model.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698