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

Side by Side Diff: components/policy/core/common/async_policy_provider.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: 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/async_policy_provider.h" 5 #include "components/policy/core/common/async_policy_provider.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"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
15 #include "components/policy/core/common/async_policy_loader.h" 15 #include "components/policy/core/common/async_policy_loader.h"
16 #include "components/policy/core/common/policy_bundle.h" 16 #include "components/policy/core/common/policy_bundle.h"
17 #include "components/policy/core/common/schema_registry.h" 17 #include "components/policy/core/common/schema_registry.h"
18 18
19 namespace policy { 19 namespace policy {
20 20
21 AsyncPolicyProvider::AsyncPolicyProvider(SchemaRegistry* registry, 21 AsyncPolicyProvider::AsyncPolicyProvider(
22 scoped_ptr<AsyncPolicyLoader> loader) 22 SchemaRegistry* registry,
23 std::unique_ptr<AsyncPolicyLoader> loader)
23 : loader_(std::move(loader)), weak_factory_(this) { 24 : loader_(std::move(loader)), weak_factory_(this) {
24 // Make an immediate synchronous load on startup. 25 // Make an immediate synchronous load on startup.
25 OnLoaderReloaded(loader_->InitialLoad(registry->schema_map())); 26 OnLoaderReloaded(loader_->InitialLoad(registry->schema_map()));
26 } 27 }
27 28
28 AsyncPolicyProvider::~AsyncPolicyProvider() { 29 AsyncPolicyProvider::~AsyncPolicyProvider() {
29 DCHECK(CalledOnValidThread()); 30 DCHECK(CalledOnValidThread());
30 } 31 }
31 32
32 void AsyncPolicyProvider::Init(SchemaRegistry* registry) { 33 void AsyncPolicyProvider::Init(SchemaRegistry* registry) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 if (!loader_) 104 if (!loader_)
104 return; 105 return;
105 106
106 loader_->task_runner()->PostTask( 107 loader_->task_runner()->PostTask(
107 FROM_HERE, 108 FROM_HERE,
108 base::Bind(&AsyncPolicyLoader::RefreshPolicies, 109 base::Bind(&AsyncPolicyLoader::RefreshPolicies,
109 base::Unretained(loader_.get()), 110 base::Unretained(loader_.get()),
110 schema_map())); 111 schema_map()));
111 } 112 }
112 113
113 void AsyncPolicyProvider::OnLoaderReloaded(scoped_ptr<PolicyBundle> bundle) { 114 void AsyncPolicyProvider::OnLoaderReloaded(
115 std::unique_ptr<PolicyBundle> bundle) {
114 DCHECK(CalledOnValidThread()); 116 DCHECK(CalledOnValidThread());
115 // Only propagate policy updates if there are no pending refreshes, and if 117 // Only propagate policy updates if there are no pending refreshes, and if
116 // Shutdown() hasn't been called yet. 118 // Shutdown() hasn't been called yet.
117 if (refresh_callback_.IsCancelled() && loader_) 119 if (refresh_callback_.IsCancelled() && loader_)
118 UpdatePolicy(std::move(bundle)); 120 UpdatePolicy(std::move(bundle));
119 } 121 }
120 122
121 // static 123 // static
122 void AsyncPolicyProvider::LoaderUpdateCallback( 124 void AsyncPolicyProvider::LoaderUpdateCallback(
123 scoped_refptr<base::SingleThreadTaskRunner> runner, 125 scoped_refptr<base::SingleThreadTaskRunner> runner,
124 base::WeakPtr<AsyncPolicyProvider> weak_this, 126 base::WeakPtr<AsyncPolicyProvider> weak_this,
125 scoped_ptr<PolicyBundle> bundle) { 127 std::unique_ptr<PolicyBundle> bundle) {
126 runner->PostTask(FROM_HERE, 128 runner->PostTask(FROM_HERE,
127 base::Bind(&AsyncPolicyProvider::OnLoaderReloaded, 129 base::Bind(&AsyncPolicyProvider::OnLoaderReloaded,
128 weak_this, 130 weak_this,
129 base::Passed(&bundle))); 131 base::Passed(&bundle)));
130 } 132 }
131 133
132 } // namespace policy 134 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698