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

Unified Diff: components/reading_list/ios/reading_list_model.cc

Issue 2763233003: Move ReadingList model to components/reading_list/core (Closed)
Patch Set: last? Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: components/reading_list/ios/reading_list_model.cc
diff --git a/components/reading_list/ios/reading_list_model.cc b/components/reading_list/ios/reading_list_model.cc
deleted file mode 100644
index ede2f8d7a69b799316e7341b0520621f69e51637..0000000000000000000000000000000000000000
--- a/components/reading_list/ios/reading_list_model.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/reading_list/ios/reading_list_model.h"
-
-#include "base/logging.h"
-#include "base/memory/ptr_util.h"
-
-ReadingListModel::ReadingListModel() : current_batch_updates_count_(0) {}
-
-ReadingListModel::~ReadingListModel() {
- for (auto& observer : observers_) {
- observer.ReadingListModelBeingDeleted(this);
- }
-}
-
-// Observer methods.
-void ReadingListModel::AddObserver(ReadingListModelObserver* observer) {
- DCHECK(CalledOnValidThread());
- DCHECK(observer);
- observers_.AddObserver(observer);
- if (loaded()) {
- observer->ReadingListModelLoaded(this);
- }
-}
-
-void ReadingListModel::RemoveObserver(ReadingListModelObserver* observer) {
- DCHECK(CalledOnValidThread());
- observers_.RemoveObserver(observer);
-}
-
-// Batch update methods.
-bool ReadingListModel::IsPerformingBatchUpdates() const {
- DCHECK(CalledOnValidThread());
- return current_batch_updates_count_ > 0;
-}
-
-std::unique_ptr<ReadingListModel::ScopedReadingListBatchUpdate>
-ReadingListModel::CreateBatchToken() {
- return base::MakeUnique<ReadingListModel::ScopedReadingListBatchUpdate>(this);
-}
-
-std::unique_ptr<ReadingListModel::ScopedReadingListBatchUpdate>
-ReadingListModel::BeginBatchUpdates() {
- DCHECK(CalledOnValidThread());
- auto token = CreateBatchToken();
-
- ++current_batch_updates_count_;
- if (current_batch_updates_count_ == 1) {
- EnteringBatchUpdates();
- }
- return token;
-}
-
-void ReadingListModel::EnteringBatchUpdates() {
- DCHECK(CalledOnValidThread());
- for (auto& observer : observers_)
- observer.ReadingListModelBeganBatchUpdates(this);
-}
-
-void ReadingListModel::EndBatchUpdates() {
- DCHECK(CalledOnValidThread());
- DCHECK(IsPerformingBatchUpdates());
- DCHECK(current_batch_updates_count_ > 0);
- --current_batch_updates_count_;
- if (current_batch_updates_count_ == 0) {
- LeavingBatchUpdates();
- }
-}
-
-void ReadingListModel::LeavingBatchUpdates() {
- DCHECK(CalledOnValidThread());
- for (auto& observer : observers_)
- observer.ReadingListModelCompletedBatchUpdates(this);
-}
-
-ReadingListModel::ScopedReadingListBatchUpdate::
- ~ScopedReadingListBatchUpdate() {
- model_->EndBatchUpdates();
-}

Powered by Google App Engine
This is Rietveld 408576698