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

Side by Side Diff: chrome/browser/sync/internal_api/sync_manager.cc

Issue 8772074: [Sync] Convert syncable/ directory to ModelEnumSet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/sync/internal_api/sync_manager.h" 5 #include "chrome/browser/sync/internal_api/sync_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 bool SignIn(const SyncCredentials& credentials); 200 bool SignIn(const SyncCredentials& credentials);
201 201
202 // Update tokens that we're using in Sync. Email must stay the same. 202 // Update tokens that we're using in Sync. Email must stay the same.
203 void UpdateCredentials(const SyncCredentials& credentials); 203 void UpdateCredentials(const SyncCredentials& credentials);
204 204
205 // Called when the user disables or enables a sync type. 205 // Called when the user disables or enables a sync type.
206 void UpdateEnabledTypes(); 206 void UpdateEnabledTypes();
207 207
208 // Conditionally sets the flag in the Nigori node which instructs other 208 // Conditionally sets the flag in the Nigori node which instructs other
209 // clients to start syncing tabs. 209 // clients to start syncing tabs.
210 void MaybeSetSyncTabsInNigoriNode(const syncable::ModelTypeSet enabled_types); 210 void MaybeSetSyncTabsInNigoriNode(syncable::ModelEnumSet enabled_types);
211 211
212 // Tell the sync engine to start the syncing process. 212 // Tell the sync engine to start the syncing process.
213 void StartSyncingNormally(); 213 void StartSyncingNormally();
214 214
215 // Whether or not the Nigori node is encrypted using an explicit passphrase. 215 // Whether or not the Nigori node is encrypted using an explicit passphrase.
216 bool IsUsingExplicitPassphrase(); 216 bool IsUsingExplicitPassphrase();
217 217
218 // Update the Cryptographer from the current nigori node and write back any 218 // Update the Cryptographer from the current nigori node and write back any
219 // necessary changes to the nigori node. We also detect missing encryption 219 // necessary changes to the nigori node. We also detect missing encryption
220 // keys and write them into the nigori node. 220 // keys and write them into the nigori node.
(...skipping 15 matching lines...) Expand all
236 236
237 // Call periodically from a database-safe thread to persist recent changes 237 // Call periodically from a database-safe thread to persist recent changes
238 // to the syncapi model. 238 // to the syncapi model.
239 void SaveChanges(); 239 void SaveChanges();
240 240
241 // DirectoryChangeDelegate implementation. 241 // DirectoryChangeDelegate implementation.
242 // This listener is called upon completion of a syncable transaction, and 242 // This listener is called upon completion of a syncable transaction, and
243 // builds the list of sync-engine initiated changes that will be forwarded to 243 // builds the list of sync-engine initiated changes that will be forwarded to
244 // the SyncManager's Observers. 244 // the SyncManager's Observers.
245 virtual void HandleTransactionCompleteChangeEvent( 245 virtual void HandleTransactionCompleteChangeEvent(
246 const ModelTypeBitSet& models_with_changes) OVERRIDE; 246 syncable::ModelEnumSet models_with_changes) OVERRIDE;
247 virtual ModelTypeBitSet HandleTransactionEndingChangeEvent( 247 virtual syncable::ModelEnumSet HandleTransactionEndingChangeEvent(
248 const ImmutableWriteTransactionInfo& write_transaction_info, 248 const ImmutableWriteTransactionInfo& write_transaction_info,
249 syncable::BaseTransaction* trans) OVERRIDE; 249 syncable::BaseTransaction* trans) OVERRIDE;
250 virtual void HandleCalculateChangesChangeEventFromSyncApi( 250 virtual void HandleCalculateChangesChangeEventFromSyncApi(
251 const ImmutableWriteTransactionInfo& write_transaction_info, 251 const ImmutableWriteTransactionInfo& write_transaction_info,
252 syncable::BaseTransaction* trans) OVERRIDE; 252 syncable::BaseTransaction* trans) OVERRIDE;
253 virtual void HandleCalculateChangesChangeEventFromSyncer( 253 virtual void HandleCalculateChangesChangeEventFromSyncer(
254 const ImmutableWriteTransactionInfo& write_transaction_info, 254 const ImmutableWriteTransactionInfo& write_transaction_info,
255 syncable::BaseTransaction* trans) OVERRIDE; 255 syncable::BaseTransaction* trans) OVERRIDE;
256 256
257 // Listens for notifications from the ServerConnectionManager 257 // Listens for notifications from the ServerConnectionManager
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 DCHECK(thread_checker_.CalledOnValidThread()); 635 DCHECK(thread_checker_.CalledOnValidThread());
636 data_->UpdateCredentials(credentials); 636 data_->UpdateCredentials(credentials);
637 } 637 }
638 638
639 void SyncManager::UpdateEnabledTypes() { 639 void SyncManager::UpdateEnabledTypes() {
640 DCHECK(thread_checker_.CalledOnValidThread()); 640 DCHECK(thread_checker_.CalledOnValidThread());
641 data_->UpdateEnabledTypes(); 641 data_->UpdateEnabledTypes();
642 } 642 }
643 643
644 void SyncManager::MaybeSetSyncTabsInNigoriNode( 644 void SyncManager::MaybeSetSyncTabsInNigoriNode(
645 const syncable::ModelTypeSet enabled_types) { 645 syncable::ModelEnumSet enabled_types) {
646 DCHECK(thread_checker_.CalledOnValidThread()); 646 DCHECK(thread_checker_.CalledOnValidThread());
647 data_->MaybeSetSyncTabsInNigoriNode(enabled_types); 647 data_->MaybeSetSyncTabsInNigoriNode(enabled_types);
648 } 648 }
649 649
650 bool SyncManager::InitialSyncEndedForAllEnabledTypes() { 650 bool SyncManager::InitialSyncEndedForAllEnabledTypes() {
651 return data_->InitialSyncEndedForAllEnabledTypes(); 651 return data_->InitialSyncEndedForAllEnabledTypes();
652 } 652 }
653 653
654 void SyncManager::StartSyncingNormally() { 654 void SyncManager::StartSyncingNormally() {
655 DCHECK(thread_checker_.CalledOnValidThread()); 655 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 void SyncManager::RequestConfig(const syncable::ModelTypeBitSet& types, 704 void SyncManager::RequestConfig(const syncable::ModelTypeBitSet& types,
705 ConfigureReason reason) { 705 ConfigureReason reason) {
706 DCHECK(thread_checker_.CalledOnValidThread()); 706 DCHECK(thread_checker_.CalledOnValidThread());
707 if (!data_->scheduler()) { 707 if (!data_->scheduler()) {
708 LOG(INFO) 708 LOG(INFO)
709 << "SyncManager::RequestConfig: bailing out because scheduler is " 709 << "SyncManager::RequestConfig: bailing out because scheduler is "
710 << "null"; 710 << "null";
711 return; 711 return;
712 } 712 }
713 StartConfigurationMode(base::Closure()); 713 StartConfigurationMode(base::Closure());
714 data_->scheduler()->ScheduleConfig(types, GetSourceFromReason(reason)); 714 data_->scheduler()->ScheduleConfig(
715 syncable::ModelTypeBitSetToEnumSet(types),
716 GetSourceFromReason(reason));
715 } 717 }
716 718
717 void SyncManager::StartConfigurationMode(const base::Closure& callback) { 719 void SyncManager::StartConfigurationMode(const base::Closure& callback) {
718 DCHECK(thread_checker_.CalledOnValidThread()); 720 DCHECK(thread_checker_.CalledOnValidThread());
719 if (!data_->scheduler()) { 721 if (!data_->scheduler()) {
720 LOG(INFO) 722 LOG(INFO)
721 << "SyncManager::StartConfigurationMode: could not start " 723 << "SyncManager::StartConfigurationMode: could not start "
722 << "configuration mode because because scheduler is null"; 724 << "configuration mode because because scheduler is null";
723 return; 725 return;
724 } 726 }
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 FROM_HERE, base::Bind(&SyncInternal::CheckServerReachable, 960 FROM_HERE, base::Bind(&SyncInternal::CheckServerReachable,
959 weak_ptr_factory_.GetWeakPtr())); 961 weak_ptr_factory_.GetWeakPtr()));
960 } 962 }
961 } 963 }
962 } 964 }
963 965
964 void SyncManager::SyncInternal::UpdateEnabledTypes() { 966 void SyncManager::SyncInternal::UpdateEnabledTypes() {
965 DCHECK(thread_checker_.CalledOnValidThread()); 967 DCHECK(thread_checker_.CalledOnValidThread());
966 ModelSafeRoutingInfo routes; 968 ModelSafeRoutingInfo routes;
967 registrar_->GetModelSafeRoutingInfo(&routes); 969 registrar_->GetModelSafeRoutingInfo(&routes);
968 syncable::ModelTypeSet enabled_types; 970 const syncable::ModelEnumSet enabled_types = GetRoutingInfoTypes(routes);
969 for (ModelSafeRoutingInfo::const_iterator it = routes.begin();
970 it != routes.end(); ++it) {
971 enabled_types.insert(it->first);
972 }
973 sync_notifier_->UpdateEnabledTypes(enabled_types); 971 sync_notifier_->UpdateEnabledTypes(enabled_types);
974 if (CommandLine::ForCurrentProcess()->HasSwitch( 972 if (CommandLine::ForCurrentProcess()->HasSwitch(
975 switches::kEnableSyncTabsForOtherClients)) { 973 switches::kEnableSyncTabsForOtherClients)) {
976 MaybeSetSyncTabsInNigoriNode(enabled_types); 974 MaybeSetSyncTabsInNigoriNode(enabled_types);
977 } 975 }
978 } 976 }
979 977
980 void SyncManager::SyncInternal::MaybeSetSyncTabsInNigoriNode( 978 void SyncManager::SyncInternal::MaybeSetSyncTabsInNigoriNode(
981 const syncable::ModelTypeSet enabled_types) { 979 const syncable::ModelEnumSet enabled_types) {
982 // The initialized_ check is to ensure that we don't CHECK in GetUserShare 980 // The initialized_ check is to ensure that we don't CHECK in GetUserShare
983 // when this is called on start-up. It's ok to ignore that case, since 981 // when this is called on start-up. It's ok to ignore that case, since
984 // presumably this would've run when the user originally enabled sessions. 982 // presumably this would've run when the user originally enabled sessions.
985 if (initialized_ && enabled_types.count(syncable::SESSIONS) > 0) { 983 if (initialized_ && enabled_types.Has(syncable::SESSIONS)) {
986 WriteTransaction trans(FROM_HERE, GetUserShare()); 984 WriteTransaction trans(FROM_HERE, GetUserShare());
987 WriteNode node(&trans); 985 WriteNode node(&trans);
988 if (!node.InitByTagLookup(kNigoriTag)) { 986 if (!node.InitByTagLookup(kNigoriTag)) {
989 NOTREACHED() << "Unable to set 'sync_tabs' bit because Nigori node not " 987 NOTREACHED() << "Unable to set 'sync_tabs' bit because Nigori node not "
990 << "found."; 988 << "found.";
991 return; 989 return;
992 } 990 }
993 991
994 sync_pb::NigoriSpecifics specifics(node.GetNigoriSpecifics()); 992 sync_pb::NigoriSpecifics specifics(node.GetNigoriSpecifics());
995 specifics.set_sync_tabs(true); 993 specifics.set_sync_tabs(true);
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 } 1344 }
1347 1345
1348 if (event.connection_code == 1346 if (event.connection_code ==
1349 browser_sync::HttpResponse::SYNC_SERVER_ERROR) { 1347 browser_sync::HttpResponse::SYNC_SERVER_ERROR) {
1350 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, 1348 FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
1351 OnAuthError(AuthError(AuthError::CONNECTION_FAILED))); 1349 OnAuthError(AuthError(AuthError::CONNECTION_FAILED)));
1352 } 1350 }
1353 } 1351 }
1354 1352
1355 void SyncManager::SyncInternal::HandleTransactionCompleteChangeEvent( 1353 void SyncManager::SyncInternal::HandleTransactionCompleteChangeEvent(
1356 const syncable::ModelTypeBitSet& models_with_changes) { 1354 syncable::ModelEnumSet models_with_changes) {
1357 // This notification happens immediately after the transaction mutex is 1355 // This notification happens immediately after the transaction mutex is
1358 // released. This allows work to be performed without blocking other threads 1356 // released. This allows work to be performed without blocking other threads
1359 // from acquiring a transaction. 1357 // from acquiring a transaction.
1360 if (!change_delegate_) 1358 if (!change_delegate_)
1361 return; 1359 return;
1362 1360
1363 // Call commit. 1361 // Call commit.
1364 for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) { 1362 for (syncable::ModelEnumSet::Iterator it = models_with_changes.First();
1365 const syncable::ModelType type = syncable::ModelTypeFromInt(i); 1363 it.Good(); it.Inc()) {
1366 if (models_with_changes.test(type)) { 1364 change_delegate_->OnChangesComplete(it.Get());
1367 change_delegate_->OnChangesComplete(type); 1365 change_observer_.Call(
1368 change_observer_.Call(FROM_HERE, 1366 FROM_HERE, &SyncManager::ChangeObserver::OnChangesComplete, it.Get());
1369 &SyncManager::ChangeObserver::OnChangesComplete, type);
1370 }
1371 } 1367 }
1372 } 1368 }
1373 1369
1374 ModelTypeBitSet SyncManager::SyncInternal::HandleTransactionEndingChangeEvent( 1370 syncable::ModelEnumSet
1375 const ImmutableWriteTransactionInfo& write_transaction_info, 1371 SyncManager::SyncInternal::HandleTransactionEndingChangeEvent(
1376 syncable::BaseTransaction* trans) { 1372 const ImmutableWriteTransactionInfo& write_transaction_info,
1373 syncable::BaseTransaction* trans) {
1377 // This notification happens immediately before a syncable WriteTransaction 1374 // This notification happens immediately before a syncable WriteTransaction
1378 // falls out of scope. It happens while the channel mutex is still held, 1375 // falls out of scope. It happens while the channel mutex is still held,
1379 // and while the transaction mutex is held, so it cannot be re-entrant. 1376 // and while the transaction mutex is held, so it cannot be re-entrant.
1380 if (!change_delegate_ || ChangeBuffersAreEmpty()) 1377 if (!change_delegate_ || ChangeBuffersAreEmpty())
1381 return ModelTypeBitSet(); 1378 return syncable::ModelEnumSet();
1382 1379
1383 // This will continue the WriteTransaction using a read only wrapper. 1380 // This will continue the WriteTransaction using a read only wrapper.
1384 // This is the last chance for read to occur in the WriteTransaction 1381 // This is the last chance for read to occur in the WriteTransaction
1385 // that's closing. This special ReadTransaction will not close the 1382 // that's closing. This special ReadTransaction will not close the
1386 // underlying transaction. 1383 // underlying transaction.
1387 ReadTransaction read_trans(GetUserShare(), trans); 1384 ReadTransaction read_trans(GetUserShare(), trans);
1388 1385
1389 syncable::ModelTypeBitSet models_with_changes; 1386 syncable::ModelEnumSet models_with_changes;
1390 for (int i = syncable::FIRST_REAL_MODEL_TYPE; 1387 for (int i = syncable::FIRST_REAL_MODEL_TYPE;
1391 i < syncable::MODEL_TYPE_COUNT; ++i) { 1388 i < syncable::MODEL_TYPE_COUNT; ++i) {
1392 const syncable::ModelType type = syncable::ModelTypeFromInt(i); 1389 const syncable::ModelType type = syncable::ModelTypeFromInt(i);
1393 if (change_buffers_[type].IsEmpty()) 1390 if (change_buffers_[type].IsEmpty())
1394 continue; 1391 continue;
1395 1392
1396 ImmutableChangeRecordList ordered_changes; 1393 ImmutableChangeRecordList ordered_changes;
1397 // TODO(akalin): Propagate up the error further (see 1394 // TODO(akalin): Propagate up the error further (see
1398 // http://crbug.com/100907). 1395 // http://crbug.com/100907).
1399 CHECK(change_buffers_[type].GetAllChangesInTreeOrder(&read_trans, 1396 CHECK(change_buffers_[type].GetAllChangesInTreeOrder(&read_trans,
1400 &ordered_changes)); 1397 &ordered_changes));
1401 if (!ordered_changes.Get().empty()) { 1398 if (!ordered_changes.Get().empty()) {
1402 change_delegate_-> 1399 change_delegate_->
1403 OnChangesApplied(type, &read_trans, ordered_changes); 1400 OnChangesApplied(type, &read_trans, ordered_changes);
1404 change_observer_.Call(FROM_HERE, 1401 change_observer_.Call(FROM_HERE,
1405 &SyncManager::ChangeObserver::OnChangesApplied, 1402 &SyncManager::ChangeObserver::OnChangesApplied,
1406 type, write_transaction_info.Get().id, ordered_changes); 1403 type, write_transaction_info.Get().id, ordered_changes);
1407 models_with_changes.set(i, true); 1404 models_with_changes.Put(type);
1408 } 1405 }
1409 change_buffers_[i].Clear(); 1406 change_buffers_[i].Clear();
1410 } 1407 }
1411 return models_with_changes; 1408 return models_with_changes;
1412 } 1409 }
1413 1410
1414 void SyncManager::SyncInternal::HandleCalculateChangesChangeEventFromSyncApi( 1411 void SyncManager::SyncInternal::HandleCalculateChangesChangeEventFromSyncApi(
1415 const ImmutableWriteTransactionInfo& write_transaction_info, 1412 const ImmutableWriteTransactionInfo& write_transaction_info,
1416 syncable::BaseTransaction* trans) { 1413 syncable::BaseTransaction* trans) {
1417 if (!scheduler()) { 1414 if (!scheduler()) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 1531
1535 SyncManager::Status SyncManager::SyncInternal::GetStatus() { 1532 SyncManager::Status SyncManager::SyncInternal::GetStatus() {
1536 return allstatus_.status(); 1533 return allstatus_.status();
1537 } 1534 }
1538 1535
1539 void SyncManager::SyncInternal::RequestNudge( 1536 void SyncManager::SyncInternal::RequestNudge(
1540 const tracked_objects::Location& location) { 1537 const tracked_objects::Location& location) {
1541 if (scheduler()) 1538 if (scheduler())
1542 scheduler()->ScheduleNudge( 1539 scheduler()->ScheduleNudge(
1543 TimeDelta::FromMilliseconds(0), browser_sync::NUDGE_SOURCE_LOCAL, 1540 TimeDelta::FromMilliseconds(0), browser_sync::NUDGE_SOURCE_LOCAL,
1544 ModelTypeBitSet(), location); 1541 syncable::ModelEnumSet(), location);
1545 } 1542 }
1546 1543
1547 void SyncManager::SyncInternal::RequestNudgeForDataType( 1544 void SyncManager::SyncInternal::RequestNudgeForDataType(
1548 const tracked_objects::Location& nudge_location, 1545 const tracked_objects::Location& nudge_location,
1549 const ModelType& type) { 1546 const ModelType& type) {
1550 if (!scheduler()) { 1547 if (!scheduler()) {
1551 NOTREACHED(); 1548 NOTREACHED();
1552 return; 1549 return;
1553 } 1550 }
1554 base::TimeDelta nudge_delay; 1551 base::TimeDelta nudge_delay;
1555 switch (type) { 1552 switch (type) {
1556 case syncable::PREFERENCES: 1553 case syncable::PREFERENCES:
1557 nudge_delay = 1554 nudge_delay =
1558 TimeDelta::FromMilliseconds(kPreferencesNudgeDelayMilliseconds); 1555 TimeDelta::FromMilliseconds(kPreferencesNudgeDelayMilliseconds);
1559 break; 1556 break;
1560 case syncable::SESSIONS: 1557 case syncable::SESSIONS:
1561 nudge_delay = scheduler()->sessions_commit_delay(); 1558 nudge_delay = scheduler()->sessions_commit_delay();
1562 break; 1559 break;
1563 default: 1560 default:
1564 nudge_delay = 1561 nudge_delay =
1565 TimeDelta::FromMilliseconds(kDefaultNudgeDelayMilliseconds); 1562 TimeDelta::FromMilliseconds(kDefaultNudgeDelayMilliseconds);
1566 break; 1563 break;
1567 } 1564 }
1568 syncable::ModelTypeBitSet types;
1569 types.set(type);
1570 scheduler()->ScheduleNudge(nudge_delay, 1565 scheduler()->ScheduleNudge(nudge_delay,
1571 browser_sync::NUDGE_SOURCE_LOCAL, 1566 browser_sync::NUDGE_SOURCE_LOCAL,
1572 types, 1567 syncable::ModelEnumSet(type),
1573 nudge_location); 1568 nudge_location);
1574 } 1569 }
1575 1570
1576 void SyncManager::SyncInternal::OnSyncEngineEvent( 1571 void SyncManager::SyncInternal::OnSyncEngineEvent(
1577 const SyncEngineEvent& event) { 1572 const SyncEngineEvent& event) {
1578 DCHECK(thread_checker_.CalledOnValidThread()); 1573 DCHECK(thread_checker_.CalledOnValidThread());
1579 // Only send an event if this is due to a cycle ending and this cycle 1574 // Only send an event if this is due to a cycle ending and this cycle
1580 // concludes a canonical "sync" process; that is, based on what is known 1575 // concludes a canonical "sync" process; that is, based on what is known
1581 // locally we are "all happy" and up-to-date. There may be new changes on 1576 // locally we are "all happy" and up-to-date. There may be new changes on
1582 // the server, but we'll get them on a subsequent sync. 1577 // the server, but we'll get them on a subsequent sync.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 1619
1625 // This is here for tests, which are still using p2p notifications. 1620 // This is here for tests, which are still using p2p notifications.
1626 // 1621 //
1627 // TODO(chron): Consider changing this back to track has_more_to_sync 1622 // TODO(chron): Consider changing this back to track has_more_to_sync
1628 // only notify peers if a successful commit has occurred. 1623 // only notify peers if a successful commit has occurred.
1629 bool is_notifiable_commit = 1624 bool is_notifiable_commit =
1630 (event.snapshot->syncer_status.num_successful_commits > 0); 1625 (event.snapshot->syncer_status.num_successful_commits > 0);
1631 if (is_notifiable_commit) { 1626 if (is_notifiable_commit) {
1632 allstatus_.IncrementNotifiableCommits(); 1627 allstatus_.IncrementNotifiableCommits();
1633 if (sync_notifier_.get()) { 1628 if (sync_notifier_.get()) {
1634 const syncable::ModelTypeSet& changed_types = 1629 const syncable::ModelEnumSet changed_types =
1635 syncable::ModelTypePayloadMapToSet(event.snapshot->source.types); 1630 syncable::ModelTypePayloadMapToEnumSet(
1631 event.snapshot->source.types);
1636 sync_notifier_->SendNotification(changed_types); 1632 sync_notifier_->SendNotification(changed_types);
1637 } else { 1633 } else {
1638 DVLOG(1) << "Not sending notification: sync_notifier_ is NULL"; 1634 DVLOG(1) << "Not sending notification: sync_notifier_ is NULL";
1639 } 1635 }
1640 } 1636 }
1641 } 1637 }
1642 1638
1643 if (event.what_happened == SyncEngineEvent::STOP_SYNCING_PERMANENTLY) { 1639 if (event.what_happened == SyncEngineEvent::STOP_SYNCING_PERMANENTLY) {
1644 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, 1640 FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
1645 OnStopSyncingPermanently()); 1641 OnStopSyncingPermanently());
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0); 2008 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0);
2013 } 2009 }
2014 2010
2015 void SyncManager::TriggerOnNotificationStateChangeForTest( 2011 void SyncManager::TriggerOnNotificationStateChangeForTest(
2016 bool notifications_enabled) { 2012 bool notifications_enabled) {
2017 DCHECK(thread_checker_.CalledOnValidThread()); 2013 DCHECK(thread_checker_.CalledOnValidThread());
2018 data_->OnNotificationStateChange(notifications_enabled); 2014 data_->OnNotificationStateChange(notifications_enabled);
2019 } 2015 }
2020 2016
2021 void SyncManager::TriggerOnIncomingNotificationForTest( 2017 void SyncManager::TriggerOnIncomingNotificationForTest(
2022 const syncable::ModelTypeBitSet& model_types) { 2018 syncable::ModelEnumSet model_types) {
2023 DCHECK(thread_checker_.CalledOnValidThread()); 2019 DCHECK(thread_checker_.CalledOnValidThread());
2024 syncable::ModelTypePayloadMap model_types_with_payloads = 2020 syncable::ModelTypePayloadMap model_types_with_payloads =
2025 syncable::ModelTypePayloadMapFromBitSet(model_types, 2021 syncable::ModelTypePayloadMapFromEnumSet(model_types,
2026 std::string()); 2022 std::string());
2027 2023
2028 data_->OnIncomingNotification(model_types_with_payloads); 2024 data_->OnIncomingNotification(model_types_with_payloads);
2029 } 2025 }
2030 2026
2031 // Helper function that converts a PassphraseRequiredReason value to a string. 2027 // Helper function that converts a PassphraseRequiredReason value to a string.
2032 std::string PassphraseRequiredReasonToString( 2028 std::string PassphraseRequiredReasonToString(
2033 PassphraseRequiredReason reason) { 2029 PassphraseRequiredReason reason) {
2034 switch (reason) { 2030 switch (reason) {
2035 case REASON_PASSPHRASE_NOT_REQUIRED: 2031 case REASON_PASSPHRASE_NOT_REQUIRED:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 lookup->GetDownloadProgress(*i, &marker); 2078 lookup->GetDownloadProgress(*i, &marker);
2083 2079
2084 if (marker.token().empty()) 2080 if (marker.token().empty())
2085 result.insert(*i); 2081 result.insert(*i);
2086 2082
2087 } 2083 }
2088 return result; 2084 return result;
2089 } 2085 }
2090 2086
2091 } // namespace sync_api 2087 } // namespace sync_api
OLDNEW
« no previous file with comments | « chrome/browser/sync/internal_api/sync_manager.h ('k') | chrome/browser/sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698