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

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

Issue 15061007: Added a PolicyDomainDescriptor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments, rebase on new PolicySchema Created 7 years, 7 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) 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 "chrome/browser/policy/async_policy_provider.h" 5 #include "chrome/browser/policy/async_policy_provider.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/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // made before this call. So if a caller has modified the policy settings and 72 // made before this call. So if a caller has modified the policy settings and
73 // invoked RefreshPolicies(), then by the next notification these policies 73 // invoked RefreshPolicies(), then by the next notification these policies
74 // should already be provided. 74 // should already be provided.
75 // However, it's also possible that an asynchronous Reload() is in progress 75 // However, it's also possible that an asynchronous Reload() is in progress
76 // and just posted OnLoaderReloaded(). Therefore a task is posted to the 76 // and just posted OnLoaderReloaded(). Therefore a task is posted to the
77 // FILE thread before posting the next Reload, to prevent a potential 77 // FILE thread before posting the next Reload, to prevent a potential
78 // concurrent Reload() from triggering a notification too early. If another 78 // concurrent Reload() from triggering a notification too early. If another
79 // refresh task has been posted, it is invalidated now. 79 // refresh task has been posted, it is invalidated now.
80 refresh_callback_.Reset( 80 refresh_callback_.Reset(
81 base::Bind(&AsyncPolicyProvider::ReloadAfterRefreshSync, 81 base::Bind(&AsyncPolicyProvider::ReloadAfterRefreshSync,
82 base::Unretained(this))); 82 weak_factory_.GetWeakPtr()));
83 BrowserThread::PostTaskAndReply( 83 BrowserThread::PostTaskAndReply(
84 BrowserThread::FILE, FROM_HERE, 84 BrowserThread::FILE, FROM_HERE,
85 base::Bind(base::DoNothing), 85 base::Bind(base::DoNothing),
86 refresh_callback_.callback()); 86 refresh_callback_.callback());
87 } 87 }
88 88
89 void AsyncPolicyProvider::RegisterPolicyDomain(
90 scoped_refptr<const PolicyDomainDescriptor> descriptor) {
91 if (loader_) {
92 BrowserThread::PostTask(BrowserThread::FILE,
93 FROM_HERE,
94 base::Bind(&AsyncPolicyLoader::RegisterPolicyDomain,
95 base::Unretained(loader_),
96 descriptor));
97 }
98 }
99
89 void AsyncPolicyProvider::ReloadAfterRefreshSync() { 100 void AsyncPolicyProvider::ReloadAfterRefreshSync() {
90 DCHECK(CalledOnValidThread()); 101 DCHECK(CalledOnValidThread());
91 // This task can only enter if it was posted from RefreshPolicies(), and it 102 // This task can only enter if it was posted from RefreshPolicies(), and it
92 // hasn't been cancelled meanwhile by another call to RefreshPolicies(). 103 // hasn't been cancelled meanwhile by another call to RefreshPolicies().
93 DCHECK(!refresh_callback_.IsCancelled()); 104 DCHECK(!refresh_callback_.IsCancelled());
94 // There can't be another refresh callback pending now, since its creation 105 // There can't be another refresh callback pending now, since its creation
95 // in RefreshPolicies() would have cancelled the current execution. So it's 106 // in RefreshPolicies() would have cancelled the current execution. So it's
96 // safe to cancel the |refresh_callback_| now, so that OnLoaderReloaded() 107 // safe to cancel the |refresh_callback_| now, so that OnLoaderReloaded()
97 // sees that there is no refresh pending. 108 // sees that there is no refresh pending.
98 refresh_callback_.Cancel(); 109 refresh_callback_.Cancel();
(...skipping 22 matching lines...) Expand all
121 base::WeakPtr<AsyncPolicyProvider> weak_this, 132 base::WeakPtr<AsyncPolicyProvider> weak_this,
122 scoped_ptr<PolicyBundle> bundle) { 133 scoped_ptr<PolicyBundle> bundle) {
123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
124 loop->PostTask(FROM_HERE, 135 loop->PostTask(FROM_HERE,
125 base::Bind(&AsyncPolicyProvider::OnLoaderReloaded, 136 base::Bind(&AsyncPolicyProvider::OnLoaderReloaded,
126 weak_this, 137 weak_this,
127 base::Passed(&bundle))); 138 base::Passed(&bundle)));
128 } 139 }
129 140
130 } // namespace policy 141 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698