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 // TODO: Acknowledge only after fetch completes. See crbug.com/320878. |
satorux1
2013/11/25 01:57:46
nit: TODO should have a name.
rlarocque
2013/11/25 19:34:24
Can you suggest an owner?
Implementing this would
| |
79 // completed. http://crbug.com/156843 | 80 invalidation_map.AcknowledgeAll(); |
80 DCHECK(invalidation_service_); | |
81 syncer::Invalidation inv = invalidation_map.ForObject(object_id).back(); | |
82 invalidation_service_->AcknowledgeInvalidation(object_id, inv.ack_handle()); | |
83 | |
84 NotifyObserversToUpdate(NOTIFICATION_XMPP); | 81 NotifyObserversToUpdate(NOTIFICATION_XMPP); |
85 } | 82 } |
86 | 83 |
87 void DriveNotificationManager::AddObserver( | 84 void DriveNotificationManager::AddObserver( |
88 DriveNotificationObserver* observer) { | 85 DriveNotificationObserver* observer) { |
89 observers_.AddObserver(observer); | 86 observers_.AddObserver(observer); |
90 } | 87 } |
91 | 88 |
92 void DriveNotificationManager::RemoveObserver( | 89 void DriveNotificationManager::RemoveObserver( |
93 DriveNotificationObserver* observer) { | 90 DriveNotificationObserver* observer) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 return "NOTIFICATION_XMPP"; | 148 return "NOTIFICATION_XMPP"; |
152 case NOTIFICATION_POLLING: | 149 case NOTIFICATION_POLLING: |
153 return "NOTIFICATION_POLLING"; | 150 return "NOTIFICATION_POLLING"; |
154 } | 151 } |
155 | 152 |
156 NOTREACHED(); | 153 NOTREACHED(); |
157 return ""; | 154 return ""; |
158 } | 155 } |
159 | 156 |
160 } // namespace drive | 157 } // namespace drive |
OLD | NEW |