Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

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

Issue 12310100: Initialize BrowserPolicyConnector after the IOThread is created. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed broken test Created 7 years, 9 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 "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_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 22 matching lines...) Expand all
33 DCHECK(CalledOnValidThread()); 33 DCHECK(CalledOnValidThread());
34 ConfigurationPolicyProvider::Init(); 34 ConfigurationPolicyProvider::Init();
35 35
36 if (!loader_) 36 if (!loader_)
37 return; 37 return;
38 38
39 AsyncPolicyLoader::UpdateCallback callback = 39 AsyncPolicyLoader::UpdateCallback callback =
40 base::Bind(&AsyncPolicyProvider::LoaderUpdateCallback, 40 base::Bind(&AsyncPolicyProvider::LoaderUpdateCallback,
41 base::MessageLoopProxy::current(), 41 base::MessageLoopProxy::current(),
42 weak_factory_.GetWeakPtr()); 42 weak_factory_.GetWeakPtr());
43 BrowserThread::PostTask( 43 bool post = BrowserThread::PostTask(
44 BrowserThread::FILE, FROM_HERE, 44 BrowserThread::FILE, FROM_HERE,
45 base::Bind(&AsyncPolicyLoader::Init, 45 base::Bind(&AsyncPolicyLoader::Init,
46 base::Unretained(loader_), 46 base::Unretained(loader_),
47 callback)); 47 callback));
48 DCHECK(post) << "AsyncPolicyProvider::Init() called with threads not running";
48 } 49 }
49 50
50 void AsyncPolicyProvider::Shutdown() { 51 void AsyncPolicyProvider::Shutdown() {
51 DCHECK(CalledOnValidThread()); 52 DCHECK(CalledOnValidThread());
52 // Note on the lifetime of |loader_|: 53 // Note on the lifetime of |loader_|:
53 // The |loader_| lives on the FILE thread, and is deleted from here. This 54 // The |loader_| lives on the FILE thread, and is deleted from here. This
54 // means that posting tasks on the |loader_| to FILE from the 55 // means that posting tasks on the |loader_| to FILE from the
55 // AsyncPolicyProvider is always safe, since a potential DeleteSoon() is only 56 // AsyncPolicyProvider is always safe, since a potential DeleteSoon() is only
56 // posted from here. The |loader_| posts back to the AsyncPolicyProvider 57 // posted from here. The |loader_| posts back to the AsyncPolicyProvider
57 // through the |update_callback_|, which has a WeakPtr to |this|. 58 // through the |update_callback_|, which has a WeakPtr to |this|.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 base::WeakPtr<AsyncPolicyProvider> weak_this, 118 base::WeakPtr<AsyncPolicyProvider> weak_this,
118 scoped_ptr<PolicyBundle> bundle) { 119 scoped_ptr<PolicyBundle> bundle) {
119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
120 loop->PostTask(FROM_HERE, 121 loop->PostTask(FROM_HERE,
121 base::Bind(&AsyncPolicyProvider::OnLoaderReloaded, 122 base::Bind(&AsyncPolicyProvider::OnLoaderReloaded,
122 weak_this, 123 weak_this,
123 base::Passed(&bundle))); 124 base::Passed(&bundle)));
124 } 125 }
125 126
126 } // namespace policy 127 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/ui/idle_logout_dialog_view_browsertest.cc ('k') | chrome/browser/policy/browser_policy_connector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698