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/drive/drive_notification_manager.h" | 5 #include "chrome/browser/drive/drive_notification_manager.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/drive/drive_notification_observer.h" | 8 #include "chrome/browser/drive/drive_notification_observer.h" |
9 #include "chrome/browser/invalidation/invalidation_service.h" | 9 #include "chrome/browser/invalidation/invalidation_service.h" |
10 #include "chrome/browser/invalidation/invalidation_service_factory.h" | 10 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
11 #include "google/cacheinvalidation/types.pb.h" | 11 #include "google/cacheinvalidation/types.pb.h" |
| 12 #include "sync/notifier/object_id_invalidation_map.h" |
12 | 13 |
13 namespace drive { | 14 namespace drive { |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 // The polling interval time is used when XMPP is disabled. | 18 // The polling interval time is used when XMPP is disabled. |
18 const int kFastPollingIntervalInSecs = 60; | 19 const int kFastPollingIntervalInSecs = 60; |
19 | 20 |
20 // The polling interval time is used when XMPP is enabled. Theoretically | 21 // The polling interval time is used when XMPP is enabled. Theoretically |
21 // polling should be unnecessary if XMPP is enabled, but just in case. | 22 // polling should be unnecessary if XMPP is enabled, but just in case. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 void DriveNotificationManager::OnIncomingInvalidation( | 69 void DriveNotificationManager::OnIncomingInvalidation( |
69 const syncer::ObjectIdInvalidationMap& invalidation_map) { | 70 const syncer::ObjectIdInvalidationMap& invalidation_map) { |
70 DVLOG(2) << "XMPP Drive Notification Received"; | 71 DVLOG(2) << "XMPP Drive Notification Received"; |
71 syncer::ObjectIdSet ids = invalidation_map.GetObjectIds(); | 72 syncer::ObjectIdSet ids = invalidation_map.GetObjectIds(); |
72 DCHECK_EQ(1U, ids.size()); | 73 DCHECK_EQ(1U, ids.size()); |
73 const invalidation::ObjectId object_id( | 74 const invalidation::ObjectId object_id( |
74 ipc::invalidation::ObjectSource::COSMO_CHANGELOG, | 75 ipc::invalidation::ObjectSource::COSMO_CHANGELOG, |
75 kDriveInvalidationObjectId); | 76 kDriveInvalidationObjectId); |
76 DCHECK_EQ(1U, ids.count(object_id)); | 77 DCHECK_EQ(1U, ids.count(object_id)); |
77 | 78 |
78 // TODO(dcheng): Only acknowledge the invalidation once the fetch has | 79 // This effectively disables 'local acks'. It tells the invalidations system |
79 // completed. http://crbug.com/156843 | 80 // to not bother saving invalidations across restarts for us. |
80 DCHECK(invalidation_service_); | 81 // See crbug.com/320878. |
81 syncer::Invalidation inv = invalidation_map.ForObject(object_id).back(); | 82 invalidation_map.AcknowledgeAll(); |
82 invalidation_service_->AcknowledgeInvalidation(object_id, inv.ack_handle()); | |
83 | |
84 NotifyObserversToUpdate(NOTIFICATION_XMPP); | 83 NotifyObserversToUpdate(NOTIFICATION_XMPP); |
85 } | 84 } |
86 | 85 |
87 void DriveNotificationManager::AddObserver( | 86 void DriveNotificationManager::AddObserver( |
88 DriveNotificationObserver* observer) { | 87 DriveNotificationObserver* observer) { |
89 observers_.AddObserver(observer); | 88 observers_.AddObserver(observer); |
90 } | 89 } |
91 | 90 |
92 void DriveNotificationManager::RemoveObserver( | 91 void DriveNotificationManager::RemoveObserver( |
93 DriveNotificationObserver* observer) { | 92 DriveNotificationObserver* observer) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return "NOTIFICATION_XMPP"; | 150 return "NOTIFICATION_XMPP"; |
152 case NOTIFICATION_POLLING: | 151 case NOTIFICATION_POLLING: |
153 return "NOTIFICATION_POLLING"; | 152 return "NOTIFICATION_POLLING"; |
154 } | 153 } |
155 | 154 |
156 NOTREACHED(); | 155 NOTREACHED(); |
157 return ""; | 156 return ""; |
158 } | 157 } |
159 | 158 |
160 } // namespace drive | 159 } // namespace drive |
OLD | NEW |