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

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

Issue 1276853003: Revert of Send GCM id to DMServer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 368
369 request->set_asset_id(asset_id); 369 request->set_asset_id(asset_id);
370 request->set_location(location); 370 request->set_location(location);
371 371
372 const DeviceManagementRequestJob::Callback job_callback = 372 const DeviceManagementRequestJob::Callback job_callback =
373 base::Bind(&CloudPolicyClient::OnDeviceAttributeUpdated, 373 base::Bind(&CloudPolicyClient::OnDeviceAttributeUpdated,
374 base::Unretained(this), request_job.get(), callback); 374 base::Unretained(this), request_job.get(), callback);
375 375
376 request_jobs_.push_back(request_job.Pass()); 376 request_jobs_.push_back(request_job.Pass());
377 request_jobs_.back()->Start(job_callback); 377 request_jobs_.back()->Start(job_callback);
378 }
379
380 void CloudPolicyClient::UpdateGcmId(
381 const std::string& gcm_id,
382 const CloudPolicyClient::StatusCallback& callback) {
383 CHECK(is_registered());
384
385 scoped_ptr<DeviceManagementRequestJob> request_job(service_->CreateJob(
386 DeviceManagementRequestJob::TYPE_GCM_ID_UPDATE, GetRequestContext()));
387
388 request_job->SetDMToken(dm_token_);
389 request_job->SetClientID(client_id_);
390
391 em::GcmIdUpdateRequest* const request =
392 request_job->GetRequest()->mutable_gcm_id_update_request();
393
394 request->set_gcm_id(gcm_id);
395
396 const DeviceManagementRequestJob::Callback job_callback =
397 base::Bind(&CloudPolicyClient::OnGcmIdUpdated, base::Unretained(this),
398 request_job.get(), callback);
399
400 request_jobs_.push_back(request_job.Pass());
401 request_jobs_.back()->Start(job_callback);
402 } 378 }
403 379
404 void CloudPolicyClient::AddObserver(Observer* observer) { 380 void CloudPolicyClient::AddObserver(Observer* observer) {
405 observers_.AddObserver(observer); 381 observers_.AddObserver(observer);
406 } 382 }
407 383
408 void CloudPolicyClient::RemoveObserver(Observer* observer) { 384 void CloudPolicyClient::RemoveObserver(Observer* observer) {
409 observers_.RemoveObserver(observer); 385 observers_.RemoveObserver(observer);
410 } 386 }
411 387
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 commands.push_back(command); 658 commands.push_back(command);
683 } else { 659 } else {
684 status = DM_STATUS_RESPONSE_DECODING_ERROR; 660 status = DM_STATUS_RESPONSE_DECODING_ERROR;
685 } 661 }
686 } 662 }
687 callback.Run(status, commands); 663 callback.Run(status, commands);
688 // Must call RemoveJob() last, because it frees |callback|. 664 // Must call RemoveJob() last, because it frees |callback|.
689 RemoveJob(job); 665 RemoveJob(job);
690 } 666 }
691 667
692 void CloudPolicyClient::OnGcmIdUpdated(
693 const DeviceManagementRequestJob* job,
694 const StatusCallback& callback,
695 DeviceManagementStatus status,
696 int net_error,
697 const enterprise_management::DeviceManagementResponse& response) {
698 status_ = status;
699 if (status != DM_STATUS_SUCCESS)
700 NotifyClientError();
701
702 callback.Run(status == DM_STATUS_SUCCESS);
703 RemoveJob(job);
704 }
705
706 void CloudPolicyClient::NotifyPolicyFetched() { 668 void CloudPolicyClient::NotifyPolicyFetched() {
707 FOR_EACH_OBSERVER(Observer, observers_, OnPolicyFetched(this)); 669 FOR_EACH_OBSERVER(Observer, observers_, OnPolicyFetched(this));
708 } 670 }
709 671
710 void CloudPolicyClient::NotifyRegistrationStateChanged() { 672 void CloudPolicyClient::NotifyRegistrationStateChanged() {
711 FOR_EACH_OBSERVER(Observer, observers_, OnRegistrationStateChanged(this)); 673 FOR_EACH_OBSERVER(Observer, observers_, OnRegistrationStateChanged(this));
712 } 674 }
713 675
714 void CloudPolicyClient::NotifyRobotAuthCodesFetched() { 676 void CloudPolicyClient::NotifyRobotAuthCodesFetched() {
715 FOR_EACH_OBSERVER(Observer, observers_, OnRobotAuthCodesFetched(this)); 677 FOR_EACH_OBSERVER(Observer, observers_, OnRobotAuthCodesFetched(this));
716 } 678 }
717 679
718 void CloudPolicyClient::NotifyClientError() { 680 void CloudPolicyClient::NotifyClientError() {
719 FOR_EACH_OBSERVER(Observer, observers_, OnClientError(this)); 681 FOR_EACH_OBSERVER(Observer, observers_, OnClientError(this));
720 } 682 }
721 683
722 } // namespace policy 684 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698