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

Side by Side Diff: chrome/browser/chromeos/policy/device_cloud_policy_invalidator.cc

Issue 460573005: Pass highest handled invalidation version between invalidators (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed nits. Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/policy/device_cloud_policy_invalidator.h" 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_invalidator.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 OnIncomingInvalidation( 111 OnIncomingInvalidation(
112 const syncer::ObjectIdInvalidationMap& invalidation_map) { 112 const syncer::ObjectIdInvalidationMap& invalidation_map) {
113 } 113 }
114 114
115 std::string DeviceCloudPolicyInvalidator::InvalidationServiceObserver:: 115 std::string DeviceCloudPolicyInvalidator::InvalidationServiceObserver::
116 GetOwnerName() const { 116 GetOwnerName() const {
117 return "DevicePolicy"; 117 return "DevicePolicy";
118 } 118 }
119 119
120 DeviceCloudPolicyInvalidator::DeviceCloudPolicyInvalidator() 120 DeviceCloudPolicyInvalidator::DeviceCloudPolicyInvalidator()
121 : invalidation_service_(NULL) { 121 : invalidation_service_(NULL),
122 highest_handled_invalidation_version_(0) {
122 // The DeviceCloudPolicyInvalidator should be created before any user 123 // The DeviceCloudPolicyInvalidator should be created before any user
123 // Profiles. 124 // Profiles.
124 DCHECK(g_browser_process->profile_manager()->GetLoadedProfiles().empty()); 125 DCHECK(g_browser_process->profile_manager()->GetLoadedProfiles().empty());
125 126
126 // Subscribe to notification about new user profiles becoming available. 127 // Subscribe to notification about new user profiles becoming available.
127 registrar_.Add(this, 128 registrar_.Add(this,
128 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 129 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
129 content::NotificationService::AllSources()); 130 content::NotificationService::AllSources());
130 131
131 TryToCreateInvalidator(); 132 TryToCreateInvalidator();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // |CloudPolicyInvalidator| backed by it. Otherwise, a 245 // |CloudPolicyInvalidator| backed by it. Otherwise, a
245 // |CloudPolicyInvalidator| will be created later when a connected service 246 // |CloudPolicyInvalidator| will be created later when a connected service
246 // becomes available. 247 // becomes available.
247 CreateInvalidator(device_invalidation_service_.get()); 248 CreateInvalidator(device_invalidation_service_.get());
248 } 249 }
249 } 250 }
250 251
251 void DeviceCloudPolicyInvalidator::CreateInvalidator( 252 void DeviceCloudPolicyInvalidator::CreateInvalidator(
252 invalidation::InvalidationService* invalidation_service) { 253 invalidation::InvalidationService* invalidation_service) {
253 invalidation_service_ = invalidation_service; 254 invalidation_service_ = invalidation_service;
255 DCHECK(!invalidator_);
254 invalidator_.reset(new CloudPolicyInvalidator( 256 invalidator_.reset(new CloudPolicyInvalidator(
255 enterprise_management::DeviceRegisterRequest::DEVICE, 257 enterprise_management::DeviceRegisterRequest::DEVICE,
256 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> 258 g_browser_process->platform_part()->browser_policy_connector_chromeos()->
257 GetDeviceCloudPolicyManager()->core(), 259 GetDeviceCloudPolicyManager()->core(),
258 base::MessageLoopProxy::current(), 260 base::MessageLoopProxy::current(),
259 scoped_ptr<base::Clock>(new base::DefaultClock()))); 261 scoped_ptr<base::Clock>(new base::DefaultClock()),
262 highest_handled_invalidation_version_));
260 invalidator_->Initialize(invalidation_service); 263 invalidator_->Initialize(invalidation_service);
261 } 264 }
262 265
263 void DeviceCloudPolicyInvalidator::DestroyInvalidator() { 266 void DeviceCloudPolicyInvalidator::DestroyInvalidator() {
264 if (invalidator_) 267 if (invalidator_) {
268 highest_handled_invalidation_version_ =
269 invalidator_->highest_handled_invalidation_version();
265 invalidator_->Shutdown(); 270 invalidator_->Shutdown();
271 }
266 invalidator_.reset(); 272 invalidator_.reset();
267 invalidation_service_ = NULL; 273 invalidation_service_ = NULL;
268 } 274 }
269 275
270 void DeviceCloudPolicyInvalidator::DestroyDeviceInvalidationService() { 276 void DeviceCloudPolicyInvalidator::DestroyDeviceInvalidationService() {
271 device_invalidation_service_observer_.reset(); 277 device_invalidation_service_observer_.reset();
272 device_invalidation_service_.reset(); 278 device_invalidation_service_.reset();
273 } 279 }
274 280
275 } // namespace policy 281 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698