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

Side by Side Diff: components/reading_list/ios/reading_list_store.h

Issue 2623723002: [Sync] Remove ModelError::IsSet() in favor of base::Optional. (Closed)
Patch Set: Rebase. Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_H_ 5 #ifndef COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_H_
6 #define COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_H_ 6 #define COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_H_
7 7
8 #include "base/threading/non_thread_safe.h" 8 #include "base/threading/non_thread_safe.h"
9 #include "components/reading_list/ios/reading_list_model_storage.h" 9 #include "components/reading_list/ios/reading_list_model_storage.h"
10 #include "components/reading_list/ios/reading_list_store_delegate.h" 10 #include "components/reading_list/ios/reading_list_store_delegate.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // keys in the |entity_data_map| will have been created via GetClientTag(...), 48 // keys in the |entity_data_map| will have been created via GetClientTag(...),
49 // and if a local and sync data should match/merge but disagree on tags, the 49 // and if a local and sync data should match/merge but disagree on tags, the
50 // service should use the sync data's tag. Any local pieces of data that are 50 // service should use the sync data's tag. Any local pieces of data that are
51 // not present in sync should immediately be Put(...) to the processor before 51 // not present in sync should immediately be Put(...) to the processor before
52 // returning. The same MetadataChangeList that was passed into this function 52 // returning. The same MetadataChangeList that was passed into this function
53 // can be passed to Put(...) calls. Delete(...) can also be called but should 53 // can be passed to Put(...) calls. Delete(...) can also be called but should
54 // not be needed for most model types. Durable storage writes, if not able to 54 // not be needed for most model types. Durable storage writes, if not able to
55 // combine all change atomically, should save the metadata after the data 55 // combine all change atomically, should save the metadata after the data
56 // changes, so that this merge will be re-driven by sync if is not completely 56 // changes, so that this merge will be re-driven by sync if is not completely
57 // saved during the current run. 57 // saved during the current run.
58 syncer::ModelError MergeSyncData( 58 base::Optional<syncer::ModelError> MergeSyncData(
59 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, 59 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list,
60 syncer::EntityDataMap entity_data_map) override; 60 syncer::EntityDataMap entity_data_map) override;
61 61
62 // Apply changes from the sync server locally. 62 // Apply changes from the sync server locally.
63 // Please note that |entity_changes| might have fewer entries than 63 // Please note that |entity_changes| might have fewer entries than
64 // |metadata_change_list| in case when some of the data changes are filtered 64 // |metadata_change_list| in case when some of the data changes are filtered
65 // out, or even be empty in case when a commit confirmation is processed and 65 // out, or even be empty in case when a commit confirmation is processed and
66 // only the metadata needs to persisted. 66 // only the metadata needs to persisted.
67 syncer::ModelError ApplySyncChanges( 67 base::Optional<syncer::ModelError> ApplySyncChanges(
68 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, 68 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list,
69 syncer::EntityChangeList entity_changes) override; 69 syncer::EntityChangeList entity_changes) override;
70 70
71 // Returns whether entries respect a strict order for sync and if |rhs| can be 71 // Returns whether entries respect a strict order for sync and if |rhs| can be
72 // submitted to sync after |lhs| has been received. 72 // submitted to sync after |lhs| has been received.
73 // The order should ensure that there is no sync loop in sync and should be 73 // The order should ensure that there is no sync loop in sync and should be
74 // submitted to sync in strictly increasing order. 74 // submitted to sync in strictly increasing order.
75 // Entries are in increasing order if all the fields respect increasing order. 75 // Entries are in increasing order if all the fields respect increasing order.
76 // - URL must be the same. 76 // - URL must be the same.
77 // - update_title_time_us: 77 // - update_title_time_us:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 }; 141 };
142 142
143 private: 143 private:
144 void BeginTransaction(); 144 void BeginTransaction();
145 void CommitTransaction(); 145 void CommitTransaction();
146 // Callbacks needed for the database handling. 146 // Callbacks needed for the database handling.
147 void OnDatabaseLoad( 147 void OnDatabaseLoad(
148 syncer::ModelTypeStore::Result result, 148 syncer::ModelTypeStore::Result result,
149 std::unique_ptr<syncer::ModelTypeStore::RecordList> entries); 149 std::unique_ptr<syncer::ModelTypeStore::RecordList> entries);
150 void OnDatabaseSave(syncer::ModelTypeStore::Result result); 150 void OnDatabaseSave(syncer::ModelTypeStore::Result result);
151 void OnReadAllMetadata(syncer::ModelError error, 151 void OnReadAllMetadata(base::Optional<syncer::ModelError> error,
152 std::unique_ptr<syncer::MetadataBatch> metadata_batch); 152 std::unique_ptr<syncer::MetadataBatch> metadata_batch);
153 153
154 void AddEntryToBatch(syncer::MutableDataBatch* batch, 154 void AddEntryToBatch(syncer::MutableDataBatch* batch,
155 const ReadingListEntry& entry); 155 const ReadingListEntry& entry);
156 156
157 std::unique_ptr<syncer::ModelTypeStore> store_; 157 std::unique_ptr<syncer::ModelTypeStore> store_;
158 ReadingListModel* model_; 158 ReadingListModel* model_;
159 ReadingListStoreDelegate* delegate_; 159 ReadingListStoreDelegate* delegate_;
160 StoreFactoryFunction create_store_callback_; 160 StoreFactoryFunction create_store_callback_;
161 161
162 int pending_transaction_count_; 162 int pending_transaction_count_;
163 std::unique_ptr<syncer::ModelTypeStore::WriteBatch> batch_; 163 std::unique_ptr<syncer::ModelTypeStore::WriteBatch> batch_;
164 }; 164 };
165 165
166 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_H_ 166 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698