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

Side by Side Diff: chrome/browser/chromeos/extensions/device_local_account_external_policy_loader.cc

Issue 389313003: Fix races in DeviceLocalAccountTest.Extensions* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 5 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 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 "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h" 5 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/prefs/pref_value_map.h" 9 #include "base/prefs/pref_value_map.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 DCHECK_EQ(store_, store); 74 DCHECK_EQ(store_, store);
75 } 75 }
76 76
77 void DeviceLocalAccountExternalPolicyLoader::OnExtensionListsUpdated( 77 void DeviceLocalAccountExternalPolicyLoader::OnExtensionListsUpdated(
78 const base::DictionaryValue* prefs) { 78 const base::DictionaryValue* prefs) {
79 DCHECK(external_cache_ || prefs->empty()); 79 DCHECK(external_cache_ || prefs->empty());
80 prefs_.reset(prefs->DeepCopy()); 80 prefs_.reset(prefs->DeepCopy());
81 LoadFinished(); 81 LoadFinished();
82 } 82 }
83 83
84 ExternalCache*
85 DeviceLocalAccountExternalPolicyLoader::GetExternalCacheForTesting() {
86 return external_cache_.get();
87 }
88
84 DeviceLocalAccountExternalPolicyLoader:: 89 DeviceLocalAccountExternalPolicyLoader::
85 ~DeviceLocalAccountExternalPolicyLoader() { 90 ~DeviceLocalAccountExternalPolicyLoader() {
86 DCHECK(!external_cache_); 91 DCHECK(!external_cache_);
87 } 92 }
88 93
89 void DeviceLocalAccountExternalPolicyLoader::UpdateExtensionListFromStore() { 94 void DeviceLocalAccountExternalPolicyLoader::UpdateExtensionListFromStore() {
90 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue); 95 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue);
91 const policy::PolicyMap& policy_map = store_->policy_map(); 96 const policy::PolicyMap& policy_map = store_->policy_map();
92 extensions::ExtensionInstallForcelistPolicyHandler policy_handler; 97 extensions::ExtensionInstallForcelistPolicyHandler policy_handler;
93 if (policy_handler.CheckPolicySettings(policy_map, NULL)) { 98 if (policy_handler.CheckPolicySettings(policy_map, NULL)) {
94 PrefValueMap pref_value_map; 99 PrefValueMap pref_value_map;
95 policy_handler.ApplyPolicySettings(policy_map, &pref_value_map); 100 policy_handler.ApplyPolicySettings(policy_map, &pref_value_map);
96 const base::Value* value = NULL; 101 const base::Value* value = NULL;
97 const base::DictionaryValue* dict = NULL; 102 const base::DictionaryValue* dict = NULL;
98 if (pref_value_map.GetValue(extensions::pref_names::kInstallForceList, 103 if (pref_value_map.GetValue(extensions::pref_names::kInstallForceList,
99 &value) && 104 &value) &&
100 value->GetAsDictionary(&dict)) { 105 value->GetAsDictionary(&dict)) {
101 prefs.reset(dict->DeepCopy()); 106 prefs.reset(dict->DeepCopy());
102 } 107 }
103 } 108 }
104 109
105 external_cache_->UpdateExtensionsList(prefs.Pass()); 110 external_cache_->UpdateExtensionsList(prefs.Pass());
106 } 111 }
107 112
108 } // namespace chromeos 113 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698