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

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

Issue 1902633006: Convert //components/policy from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and use namespace alias Created 4 years, 8 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_manager.h" 5 #include "components/policy/core/common/cloud/cloud_policy_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 CheckAndPublishPolicy(); 89 CheckAndPublishPolicy();
90 } 90 }
91 91
92 void CloudPolicyManager::OnComponentCloudPolicyUpdated() { 92 void CloudPolicyManager::OnComponentCloudPolicyUpdated() {
93 CheckAndPublishPolicy(); 93 CheckAndPublishPolicy();
94 } 94 }
95 95
96 void CloudPolicyManager::CheckAndPublishPolicy() { 96 void CloudPolicyManager::CheckAndPublishPolicy() {
97 if (IsInitializationComplete(POLICY_DOMAIN_CHROME) && 97 if (IsInitializationComplete(POLICY_DOMAIN_CHROME) &&
98 !waiting_for_policy_refresh_) { 98 !waiting_for_policy_refresh_) {
99 scoped_ptr<PolicyBundle> bundle(new PolicyBundle); 99 std::unique_ptr<PolicyBundle> bundle(new PolicyBundle);
100 GetChromePolicy( 100 GetChromePolicy(
101 &bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))); 101 &bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())));
102 if (component_policy_service_) 102 if (component_policy_service_)
103 bundle->MergeFrom(component_policy_service_->policy()); 103 bundle->MergeFrom(component_policy_service_->policy());
104 UpdatePolicy(std::move(bundle)); 104 UpdatePolicy(std::move(bundle));
105 } 105 }
106 } 106 }
107 107
108 void CloudPolicyManager::GetChromePolicy(PolicyMap* policy_map) { 108 void CloudPolicyManager::GetChromePolicy(PolicyMap* policy_map) {
109 policy_map->CopyFrom(store()->policy_map()); 109 policy_map->CopyFrom(store()->policy_map());
(...skipping 14 matching lines...) Expand all
124 124
125 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 125 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
126 switches::kDisableComponentCloudPolicy) || 126 switches::kDisableComponentCloudPolicy) ||
127 policy_cache_path.empty()) { 127 policy_cache_path.empty()) {
128 return; 128 return;
129 } 129 }
130 130
131 // TODO(joaodasilva): Move the |file_task_runner_| to the blocking pool. 131 // TODO(joaodasilva): Move the |file_task_runner_| to the blocking pool.
132 // Currently it's not possible because the ComponentCloudPolicyStore is 132 // Currently it's not possible because the ComponentCloudPolicyStore is
133 // NonThreadSafe and doesn't support getting calls from different threads. 133 // NonThreadSafe and doesn't support getting calls from different threads.
134 scoped_ptr<ResourceCache> resource_cache( 134 std::unique_ptr<ResourceCache> resource_cache(
135 new ResourceCache(policy_cache_path, file_task_runner_)); 135 new ResourceCache(policy_cache_path, file_task_runner_));
136 component_policy_service_.reset(new ComponentCloudPolicyService( 136 component_policy_service_.reset(new ComponentCloudPolicyService(
137 this, schema_registry(), core(), client, std::move(resource_cache), 137 this, schema_registry(), core(), client, std::move(resource_cache),
138 request_context, file_task_runner_, io_task_runner_)); 138 request_context, file_task_runner_, io_task_runner_));
139 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 139 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
140 } 140 }
141 141
142 void CloudPolicyManager::ClearAndDestroyComponentCloudPolicyService() { 142 void CloudPolicyManager::ClearAndDestroyComponentCloudPolicyService() {
143 #if !defined(OS_ANDROID) && !defined(OS_IOS) 143 #if !defined(OS_ANDROID) && !defined(OS_IOS)
144 if (component_policy_service_) { 144 if (component_policy_service_) {
145 component_policy_service_->ClearCache(); 145 component_policy_service_->ClearCache();
146 component_policy_service_.reset(); 146 component_policy_service_.reset();
147 } 147 }
148 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 148 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
149 } 149 }
150 150
151 void CloudPolicyManager::OnRefreshComplete(bool success) { 151 void CloudPolicyManager::OnRefreshComplete(bool success) {
152 waiting_for_policy_refresh_ = false; 152 waiting_for_policy_refresh_ = false;
153 CheckAndPublishPolicy(); 153 CheckAndPublishPolicy();
154 } 154 }
155 155
156 } // namespace policy 156 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698