OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/glue/sync_backend_host_core.h" | 5 #include "chrome/browser/sync/glue/sync_backend_host_core.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "chrome/browser/sync/glue/device_info.h" | 9 #include "chrome/browser/sync/glue/device_info.h" |
10 #include "chrome/browser/sync/glue/invalidation_adapter.h" | |
10 #include "chrome/browser/sync/glue/sync_backend_registrar.h" | 11 #include "chrome/browser/sync/glue/sync_backend_registrar.h" |
11 #include "chrome/browser/sync/glue/synced_device_tracker.h" | 12 #include "chrome/browser/sync/glue/synced_device_tracker.h" |
12 #include "chrome/common/chrome_version_info.h" | 13 #include "chrome/common/chrome_version_info.h" |
13 #include "sync/internal_api/public/events/protocol_event.h" | 14 #include "sync/internal_api/public/events/protocol_event.h" |
14 #include "sync/internal_api/public/http_post_provider_factory.h" | 15 #include "sync/internal_api/public/http_post_provider_factory.h" |
15 #include "sync/internal_api/public/internal_components_factory.h" | 16 #include "sync/internal_api/public/internal_components_factory.h" |
16 #include "sync/internal_api/public/sessions/commit_counters.h" | 17 #include "sync/internal_api/public/sessions/commit_counters.h" |
17 #include "sync/internal_api/public/sessions/status_counters.h" | 18 #include "sync/internal_api/public/sessions/status_counters.h" |
18 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 19 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
19 #include "sync/internal_api/public/sessions/update_counters.h" | 20 #include "sync/internal_api/public/sessions/update_counters.h" |
20 #include "sync/internal_api/public/sync_core_proxy.h" | 21 #include "sync/internal_api/public/sync_core_proxy.h" |
21 #include "sync/internal_api/public/sync_manager.h" | 22 #include "sync/internal_api/public/sync_manager.h" |
22 #include "sync/internal_api/public/sync_manager_factory.h" | 23 #include "sync/internal_api/public/sync_manager_factory.h" |
24 #include "sync/notifier/invalidation_util.h" | |
25 #include "sync/notifier/object_id_invalidation_map.h" | |
23 | 26 |
24 // Helper macros to log with the syncer thread name; useful when there | 27 // Helper macros to log with the syncer thread name; useful when there |
25 // are multiple syncers involved. | 28 // are multiple syncers involved. |
26 | 29 |
27 #define SLOG(severity) LOG(severity) << name_ << ": " | 30 #define SLOG(severity) LOG(severity) << name_ << ": " |
28 | 31 |
29 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " | 32 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " |
30 | 33 |
31 static const int kSaveChangesIntervalSeconds = 10; | 34 static const int kSaveChangesIntervalSeconds = 10; |
32 | 35 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 | 365 |
363 void SyncBackendHostCore::DoOnInvalidatorStateChange( | 366 void SyncBackendHostCore::DoOnInvalidatorStateChange( |
364 syncer::InvalidatorState state) { | 367 syncer::InvalidatorState state) { |
365 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 368 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
366 sync_manager_->OnInvalidatorStateChange(state); | 369 sync_manager_->OnInvalidatorStateChange(state); |
367 } | 370 } |
368 | 371 |
369 void SyncBackendHostCore::DoOnIncomingInvalidation( | 372 void SyncBackendHostCore::DoOnIncomingInvalidation( |
370 const syncer::ObjectIdInvalidationMap& invalidation_map) { | 373 const syncer::ObjectIdInvalidationMap& invalidation_map) { |
371 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 374 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
372 sync_manager_->OnIncomingInvalidation(invalidation_map); | 375 |
376 syncer::ObjectIdSet ids = invalidation_map.GetObjectIds(); | |
377 for (syncer::ObjectIdSet::const_iterator ids_it = ids.begin(); | |
378 ids_it != ids.end(); | |
379 ++ids_it) { | |
380 syncer::ModelType type; | |
381 if (!NotificationTypeToRealModelType(ids_it->name(), &type)) { | |
382 DLOG(WARNING) << "Notification has invalid id: " | |
383 << syncer::ObjectIdToString(*ids_it); | |
384 } else { | |
tim (not reviewing)
2014/06/20 20:47:54
This may end up being a little less efficient sinc
| |
385 syncer::SingleObjectInvalidationSet invalidation_set = | |
386 invalidation_map.ForObject(*ids_it); | |
387 for (syncer::SingleObjectInvalidationSet::const_iterator inv_it = | |
388 invalidation_set.begin(); | |
389 inv_it != invalidation_set.end(); | |
390 ++inv_it) { | |
391 scoped_ptr<syncer::InvalidationInterface> inv_adapter( | |
392 new InvalidationAdapter(*inv_it)); | |
393 sync_manager_->OnIncomingInvalidation(type, inv_adapter.Pass()); | |
394 } | |
395 } | |
396 } | |
373 } | 397 } |
374 | 398 |
375 void SyncBackendHostCore::DoInitialize( | 399 void SyncBackendHostCore::DoInitialize( |
376 scoped_ptr<DoInitializeOptions> options) { | 400 scoped_ptr<DoInitializeOptions> options) { |
377 DCHECK(!sync_loop_); | 401 DCHECK(!sync_loop_); |
378 sync_loop_ = options->sync_loop; | 402 sync_loop_ = options->sync_loop; |
379 DCHECK(sync_loop_); | 403 DCHECK(sync_loop_); |
380 | 404 |
381 // Finish initializing the HttpBridgeFactory. We do this here because | 405 // Finish initializing the HttpBridgeFactory. We do this here because |
382 // building the user agent may block on some platforms. | 406 // building the user agent may block on some platforms. |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
718 this, &SyncBackendHostCore::SaveChanges); | 742 this, &SyncBackendHostCore::SaveChanges); |
719 } | 743 } |
720 | 744 |
721 void SyncBackendHostCore::SaveChanges() { | 745 void SyncBackendHostCore::SaveChanges() { |
722 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 746 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
723 sync_manager_->SaveChanges(); | 747 sync_manager_->SaveChanges(); |
724 } | 748 } |
725 | 749 |
726 } // namespace browser_sync | 750 } // namespace browser_sync |
727 | 751 |
OLD | NEW |