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

Side by Side Diff: chrome/browser/policy/device_token_fetcher.cc

Issue 6537020: Update policy backend and testserver for the newest policy protocol (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 5 Created 9 years, 10 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/policy/device_token_fetcher.h" 5 #include "chrome/browser/policy/device_token_fetcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/policy/cloud_policy_cache.h" 10 #include "chrome/browser/policy/cloud_policy_cache.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 Initialize(service, 43 Initialize(service,
44 cache, 44 cache,
45 token_fetch_error_delay_ms, 45 token_fetch_error_delay_ms,
46 unmanaged_device_refresh_rate_ms); 46 unmanaged_device_refresh_rate_ms);
47 } 47 }
48 48
49 DeviceTokenFetcher::~DeviceTokenFetcher() { 49 DeviceTokenFetcher::~DeviceTokenFetcher() {
50 CancelRetryTask(); 50 CancelRetryTask();
51 } 51 }
52 52
53 void DeviceTokenFetcher::FetchToken(const std::string& auth_token, 53 void DeviceTokenFetcher::FetchToken(
54 const std::string& device_id) { 54 const std::string& auth_token,
55 const std::string& device_id,
56 const em::DeviceRegisterRequest_Type policy_type,
57 const std::string& machine_id) {
55 SetState(STATE_INACTIVE); 58 SetState(STATE_INACTIVE);
56 auth_token_ = auth_token; 59 auth_token_ = auth_token;
57 device_id_ = device_id; 60 device_id_ = device_id;
61 policy_type_ = policy_type;
62 machine_id_ = machine_id;
58 FetchTokenInternal(); 63 FetchTokenInternal();
59 } 64 }
60 65
61 void DeviceTokenFetcher::FetchTokenInternal() { 66 void DeviceTokenFetcher::FetchTokenInternal() {
62 DCHECK(state_ != STATE_TOKEN_AVAILABLE); 67 DCHECK(state_ != STATE_TOKEN_AVAILABLE);
63 DCHECK(!auth_token_.empty() && !device_id_.empty()); 68 DCHECK(!auth_token_.empty() && !device_id_.empty());
64 // Construct a new backend, which will discard any previous requests. 69 // Construct a new backend, which will discard any previous requests.
65 backend_.reset(service_->CreateBackend()); 70 backend_.reset(service_->CreateBackend());
66 em::DeviceRegisterRequest request; 71 em::DeviceRegisterRequest request;
72 request.set_type(policy_type_);
73 request.set_machine_id(machine_id_);
67 backend_->ProcessRegisterRequest(auth_token_, device_id_, request, this); 74 backend_->ProcessRegisterRequest(auth_token_, device_id_, request, this);
68 } 75 }
69 76
70 const std::string& DeviceTokenFetcher::GetDeviceToken() { 77 const std::string& DeviceTokenFetcher::GetDeviceToken() {
71 return device_token_; 78 return device_token_;
72 } 79 }
73 80
74 void DeviceTokenFetcher::AddObserver(DeviceTokenFetcher::Observer* observer) { 81 void DeviceTokenFetcher::AddObserver(DeviceTokenFetcher::Observer* observer) {
75 observer_list_.AddObserver(observer); 82 observer_list_.AddObserver(observer);
76 } 83 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 176 }
170 177
171 void DeviceTokenFetcher::CancelRetryTask() { 178 void DeviceTokenFetcher::CancelRetryTask() {
172 if (retry_task_) { 179 if (retry_task_) {
173 retry_task_->Cancel(); 180 retry_task_->Cancel();
174 retry_task_ = NULL; 181 retry_task_ = NULL;
175 } 182 }
176 } 183 }
177 184
178 } // namespace policy 185 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698