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

Side by Side Diff: components/policy/core/common/cloud/cloud_policy_client.cc

Issue 756133002: Purge cache when the server removes the policy for an extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/policy/core/common/cloud/cloud_policy_client.h" 5 #include "components/policy/core/common/cloud/cloud_policy_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 key_update_request->add_server_backed_state_key(*key); 213 key_update_request->add_server_backed_state_key(*key);
214 } 214 }
215 } 215 }
216 216
217 // Set the fetched invalidation version to the latest invalidation version 217 // Set the fetched invalidation version to the latest invalidation version
218 // since it is now the invalidation version used for the latest fetch. 218 // since it is now the invalidation version used for the latest fetch.
219 fetched_invalidation_version_ = invalidation_version_; 219 fetched_invalidation_version_ = invalidation_version_;
220 220
221 // Fire the job. 221 // Fire the job.
222 request_job_->Start(base::Bind(&CloudPolicyClient::OnPolicyFetchCompleted, 222 request_job_->Start(base::Bind(&CloudPolicyClient::OnPolicyFetchCompleted,
223 base::Unretained(this))); 223 base::Unretained(this),
224 namespaces_to_fetch_));
224 } 225 }
225 226
226 void CloudPolicyClient::FetchRobotAuthCodes(const std::string& auth_token) { 227 void CloudPolicyClient::FetchRobotAuthCodes(const std::string& auth_token) {
227 CHECK(is_registered()); 228 CHECK(is_registered());
228 DCHECK(!auth_token.empty()); 229 DCHECK(!auth_token.empty());
229 230
230 request_job_.reset(service_->CreateJob( 231 request_job_.reset(service_->CreateJob(
231 DeviceManagementRequestJob::TYPE_API_AUTH_CODE_FETCH, 232 DeviceManagementRequestJob::TYPE_API_AUTH_CODE_FETCH,
232 GetRequestContext())); 233 GetRequestContext()));
233 // The credentials of a domain user are needed in order to mint a new OAuth2 234 // The credentials of a domain user are needed in order to mint a new OAuth2
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 DVLOG(1) << "Device robot account auth code fetch complete - code = " 370 DVLOG(1) << "Device robot account auth code fetch complete - code = "
370 << robot_api_auth_code_; 371 << robot_api_auth_code_;
371 372
372 NotifyRobotAuthCodesFetched(); 373 NotifyRobotAuthCodesFetched();
373 } else { 374 } else {
374 NotifyClientError(); 375 NotifyClientError();
375 } 376 }
376 } 377 }
377 378
378 void CloudPolicyClient::OnPolicyFetchCompleted( 379 void CloudPolicyClient::OnPolicyFetchCompleted(
380 const NamespaceSet& namespaces_requested,
379 DeviceManagementStatus status, 381 DeviceManagementStatus status,
380 int net_error, 382 int net_error,
381 const em::DeviceManagementResponse& response) { 383 const em::DeviceManagementResponse& response) {
382 if (status == DM_STATUS_SUCCESS) { 384 if (status == DM_STATUS_SUCCESS) {
383 if (!response.has_policy_response() || 385 if (!response.has_policy_response() ||
384 response.policy_response().response_size() == 0) { 386 response.policy_response().response_size() == 0) {
385 LOG(WARNING) << "Empty policy response."; 387 LOG(WARNING) << "Empty policy response.";
386 status = DM_STATUS_RESPONSE_DECODING_ERROR; 388 status = DM_STATUS_RESPONSE_DECODING_ERROR;
387 } 389 }
388 } 390 }
389 391
390 status_ = status; 392 status_ = status;
391 if (status == DM_STATUS_SUCCESS) { 393 if (status == DM_STATUS_SUCCESS) {
394 namespaces_requested_ = namespaces_requested;
395 STLDeleteValues(&responses_);
392 const em::DevicePolicyResponse& policy_response = 396 const em::DevicePolicyResponse& policy_response =
393 response.policy_response(); 397 response.policy_response();
394 STLDeleteValues(&responses_);
395 for (int i = 0; i < policy_response.response_size(); ++i) { 398 for (int i = 0; i < policy_response.response_size(); ++i) {
396 const em::PolicyFetchResponse& response = policy_response.response(i); 399 const em::PolicyFetchResponse& response = policy_response.response(i);
397 em::PolicyData policy_data; 400 em::PolicyData policy_data;
398 if (!policy_data.ParseFromString(response.policy_data()) || 401 if (!policy_data.ParseFromString(response.policy_data()) ||
399 !policy_data.IsInitialized() || 402 !policy_data.IsInitialized() ||
400 !policy_data.has_policy_type()) { 403 !policy_data.has_policy_type()) {
401 LOG(WARNING) << "Invalid PolicyData received, ignoring"; 404 LOG(WARNING) << "Invalid PolicyData received, ignoring";
402 continue; 405 continue;
403 } 406 }
404 const std::string& type = policy_data.policy_type(); 407 const std::string& type = policy_data.policy_type();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 473
471 void CloudPolicyClient::NotifyRobotAuthCodesFetched() { 474 void CloudPolicyClient::NotifyRobotAuthCodesFetched() {
472 FOR_EACH_OBSERVER(Observer, observers_, OnRobotAuthCodesFetched(this)); 475 FOR_EACH_OBSERVER(Observer, observers_, OnRobotAuthCodesFetched(this));
473 } 476 }
474 477
475 void CloudPolicyClient::NotifyClientError() { 478 void CloudPolicyClient::NotifyClientError() {
476 FOR_EACH_OBSERVER(Observer, observers_, OnClientError(this)); 479 FOR_EACH_OBSERVER(Observer, observers_, OnClientError(this));
477 } 480 }
478 481
479 } // namespace policy 482 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698