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

Side by Side Diff: chrome/browser/chromeos/policy/device_local_account_policy_service.cc

Issue 341043005: Wire up component cloud policy to device local accounts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/chromeos/policy/device_local_account_policy_service.h" 5 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/file_enumerator.h" 11 #include "base/files/file_enumerator.h"
12 #include "base/files/file_path.h"
13 #include "base/logging.h" 12 #include "base/logging.h"
14 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
15 #include "base/message_loop/message_loop_proxy.h" 14 #include "base/message_loop/message_loop_proxy.h"
16 #include "base/path_service.h" 15 #include "base/path_service.h"
17 #include "base/sequenced_task_runner.h" 16 #include "base/sequenced_task_runner.h"
17 #include "base/stl_util.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chromeos/policy/device_local_account.h" 20 #include "chrome/browser/chromeos/policy/device_local_account.h"
21 #include "chrome/browser/chromeos/policy/device_local_account_external_data_serv ice.h" 21 #include "chrome/browser/chromeos/policy/device_local_account_external_data_serv ice.h"
22 #include "chrome/browser/chromeos/policy/device_local_account_policy_store.h" 22 #include "chrome/browser/chromeos/policy/device_local_account_policy_store.h"
23 #include "chrome/browser/chromeos/settings/device_settings_service.h" 23 #include "chrome/browser/chromeos/settings/device_settings_service.h"
24 #include "chrome/common/chrome_content_client.h" 24 #include "chrome/common/chrome_content_client.h"
25 #include "chromeos/chromeos_paths.h" 25 #include "chromeos/chromeos_paths.h"
26 #include "chromeos/dbus/session_manager_client.h" 26 #include "chromeos/dbus/session_manager_client.h"
27 #include "chromeos/settings/cros_settings_names.h" 27 #include "chromeos/settings/cros_settings_names.h"
28 #include "chromeos/settings/cros_settings_provider.h" 28 #include "chromeos/settings/cros_settings_provider.h"
29 #include "components/policy/core/common/cloud/cloud_policy_client.h" 29 #include "components/policy/core/common/cloud/cloud_policy_client.h"
30 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 30 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
31 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" 31 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h"
32 #include "components/policy/core/common/cloud/device_management_service.h" 32 #include "components/policy/core/common/cloud/device_management_service.h"
33 #include "components/policy/core/common/cloud/system_policy_request_context.h" 33 #include "components/policy/core/common/cloud/system_policy_request_context.h"
34 #include "content/public/browser/browser_thread.h"
34 #include "net/url_request/url_request_context_getter.h" 35 #include "net/url_request/url_request_context_getter.h"
35 #include "policy/policy_constants.h" 36 #include "policy/policy_constants.h"
36 #include "policy/proto/device_management_backend.pb.h" 37 #include "policy/proto/device_management_backend.pb.h"
37 #include "url/gurl.h" 38 #include "url/gurl.h"
38 39
39 namespace em = enterprise_management; 40 namespace em = enterprise_management;
40 41
41 namespace policy { 42 namespace policy {
42 43
43 namespace { 44 namespace {
(...skipping 21 matching lines...) Expand all
65 new CloudPolicyClient(std::string(), std::string(), 66 new CloudPolicyClient(std::string(), std::string(),
66 kPolicyVerificationKeyHash, 67 kPolicyVerificationKeyHash,
67 USER_AFFILIATION_MANAGED, 68 USER_AFFILIATION_MANAGED,
68 NULL, device_management_service, request_context)); 69 NULL, device_management_service, request_context));
69 client->SetupRegistration(policy_data->request_token(), 70 client->SetupRegistration(policy_data->request_token(),
70 policy_data->device_id()); 71 policy_data->device_id());
71 return client.Pass(); 72 return client.Pass();
72 } 73 }
73 74
74 // Get the subdirectory of the cache directory in which force-installed 75 // Get the subdirectory of the cache directory in which force-installed
75 // extensions are cached for |account_id|. 76 // extensions are cached for |account_id|. This is also used for the
76 std::string GetCacheSubdirectoryForAccountID(const std::string& account_id) { 77 // component policy cache.
78 std::string EncodeAccountId(const std::string& account_id) {
77 return base::HexEncode(account_id.c_str(), account_id.size()); 79 return base::HexEncode(account_id.c_str(), account_id.size());
78 } 80 }
79 81
80 // Cleans up the cache directory by removing subdirectories that are not found 82 // Cleans up the cache directory by removing subdirectories that are not found
81 // in |subdirectories_to_keep|. Only caches whose cache directory is found in 83 // in |subdirectories_to_keep|. Only caches whose cache directory is found in
82 // |subdirectories_to_keep| may be running while the clean-up is in progress. 84 // |subdirectories_to_keep| may be running while the clean-up is in progress.
83 void DeleteOrphanedExtensionCaches( 85 void DeleteOrphanedCaches(
86 const base::FilePath& cache_root_dir,
84 const std::set<std::string>& subdirectories_to_keep) { 87 const std::set<std::string>& subdirectories_to_keep) {
85 base::FilePath cache_root_dir;
86 CHECK(PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS,
87 &cache_root_dir));
88 base::FileEnumerator enumerator(cache_root_dir, 88 base::FileEnumerator enumerator(cache_root_dir,
89 false, 89 false,
90 base::FileEnumerator::DIRECTORIES); 90 base::FileEnumerator::DIRECTORIES);
91 for (base::FilePath path = enumerator.Next(); !path.empty(); 91 for (base::FilePath path = enumerator.Next(); !path.empty();
92 path = enumerator.Next()) { 92 path = enumerator.Next()) {
93 const std::string subdirectory(path.BaseName().MaybeAsASCII()); 93 const std::string subdirectory(path.BaseName().MaybeAsASCII());
94 if (subdirectories_to_keep.find(subdirectory) == 94 if (!ContainsKey(subdirectories_to_keep, subdirectory))
95 subdirectories_to_keep.end()) {
96 base::DeleteFile(path, true); 95 base::DeleteFile(path, true);
97 }
98 } 96 }
99 } 97 }
100 98
101 // Removes the subdirectory belonging to |account_id_to_delete| from the cache 99 // Removes the subdirectory belonging to |account_id_to_delete| from the cache
102 // directory. No cache belonging to |account_id_to_delete| may be running while 100 // directory. No cache belonging to |account_id_to_delete| may be running while
103 // the removal is in progress. 101 // the removal is in progress.
104 void DeleteObsoleteExtensionCache(const std::string& account_id_to_delete) { 102 void DeleteObsoleteExtensionCache(const std::string& account_id_to_delete) {
105 base::FilePath cache_root_dir; 103 base::FilePath cache_root_dir;
106 CHECK(PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS, 104 CHECK(PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS,
107 &cache_root_dir)); 105 &cache_root_dir));
108 const base::FilePath path = cache_root_dir 106 const base::FilePath path =
109 .Append(GetCacheSubdirectoryForAccountID(account_id_to_delete)); 107 cache_root_dir.Append(EncodeAccountId(account_id_to_delete));
110 if (base::DirectoryExists(path)) 108 if (base::DirectoryExists(path))
111 base::DeleteFile(path, true); 109 base::DeleteFile(path, true);
112 } 110 }
113 111
114 } // namespace 112 } // namespace
115 113
116 DeviceLocalAccountPolicyBroker::DeviceLocalAccountPolicyBroker( 114 DeviceLocalAccountPolicyBroker::DeviceLocalAccountPolicyBroker(
117 const DeviceLocalAccount& account, 115 const DeviceLocalAccount& account,
116 const base::FilePath& component_policy_cache_path,
118 scoped_ptr<DeviceLocalAccountPolicyStore> store, 117 scoped_ptr<DeviceLocalAccountPolicyStore> store,
119 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager, 118 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager,
120 const scoped_refptr<base::SequencedTaskRunner>& task_runner) 119 const scoped_refptr<base::SequencedTaskRunner>& task_runner)
121 : account_id_(account.account_id), 120 : account_id_(account.account_id),
122 user_id_(account.user_id), 121 user_id_(account.user_id),
122 component_policy_cache_path_(component_policy_cache_path),
123 store_(store.Pass()), 123 store_(store.Pass()),
124 external_data_manager_(external_data_manager), 124 external_data_manager_(external_data_manager),
125 core_(PolicyNamespaceKey(dm_protocol::kChromePublicAccountPolicyType, 125 core_(PolicyNamespaceKey(dm_protocol::kChromePublicAccountPolicyType,
126 store_->account_id()), 126 store_->account_id()),
127 store_.get(), 127 store_.get(),
128 task_runner) { 128 task_runner) {
129 base::FilePath cache_root_dir; 129 base::FilePath cache_root_dir;
130 CHECK(PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS, 130 CHECK(PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS,
131 &cache_root_dir)); 131 &cache_root_dir));
132 extension_loader_ = new chromeos::DeviceLocalAccountExternalPolicyLoader( 132 extension_loader_ = new chromeos::DeviceLocalAccountExternalPolicyLoader(
133 store_.get(), 133 store_.get(), cache_root_dir.Append(EncodeAccountId(account.account_id)));
134 cache_root_dir.Append(
135 GetCacheSubdirectoryForAccountID(account.account_id)));
136 } 134 }
137 135
138 DeviceLocalAccountPolicyBroker::~DeviceLocalAccountPolicyBroker() { 136 DeviceLocalAccountPolicyBroker::~DeviceLocalAccountPolicyBroker() {
139 external_data_manager_->SetPolicyStore(NULL); 137 external_data_manager_->SetPolicyStore(NULL);
140 external_data_manager_->Disconnect(); 138 external_data_manager_->Disconnect();
141 } 139 }
142 140
143 void DeviceLocalAccountPolicyBroker::Initialize() { 141 void DeviceLocalAccountPolicyBroker::Initialize() {
144 store_->Load(); 142 store_->Load();
145 } 143 }
(...skipping 29 matching lines...) Expand all
175 173
176 std::string DeviceLocalAccountPolicyBroker::GetDisplayName() const { 174 std::string DeviceLocalAccountPolicyBroker::GetDisplayName() const {
177 std::string display_name; 175 std::string display_name;
178 const base::Value* display_name_value = 176 const base::Value* display_name_value =
179 store_->policy_map().GetValue(policy::key::kUserDisplayName); 177 store_->policy_map().GetValue(policy::key::kUserDisplayName);
180 if (display_name_value) 178 if (display_name_value)
181 display_name_value->GetAsString(&display_name); 179 display_name_value->GetAsString(&display_name);
182 return display_name; 180 return display_name;
183 } 181 }
184 182
183 base::FilePath DeviceLocalAccountPolicyBroker::GetComponentPolicyCachePath()
184 const {
185 return component_policy_cache_path_;
186 }
187
185 DeviceLocalAccountPolicyService::DeviceLocalAccountPolicyService( 188 DeviceLocalAccountPolicyService::DeviceLocalAccountPolicyService(
186 chromeos::SessionManagerClient* session_manager_client, 189 chromeos::SessionManagerClient* session_manager_client,
187 chromeos::DeviceSettingsService* device_settings_service, 190 chromeos::DeviceSettingsService* device_settings_service,
188 chromeos::CrosSettings* cros_settings, 191 chromeos::CrosSettings* cros_settings,
189 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner, 192 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner,
190 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner, 193 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner,
191 scoped_refptr<base::SequencedTaskRunner> 194 scoped_refptr<base::SequencedTaskRunner>
192 external_data_service_backend_task_runner, 195 external_data_service_backend_task_runner,
193 scoped_refptr<base::SequencedTaskRunner> io_task_runner, 196 scoped_refptr<base::SequencedTaskRunner> io_task_runner,
194 scoped_refptr<net::URLRequestContextGetter> request_context) 197 scoped_refptr<net::URLRequestContextGetter> request_context)
195 : session_manager_client_(session_manager_client), 198 : session_manager_client_(session_manager_client),
196 device_settings_service_(device_settings_service), 199 device_settings_service_(device_settings_service),
197 cros_settings_(cros_settings), 200 cros_settings_(cros_settings),
198 device_management_service_(NULL), 201 device_management_service_(NULL),
199 waiting_for_cros_settings_(false), 202 waiting_for_cros_settings_(false),
200 orphan_cache_deletion_state_(NOT_STARTED), 203 orphan_cache_deletion_state_(NOT_STARTED),
201 store_background_task_runner_(store_background_task_runner), 204 store_background_task_runner_(store_background_task_runner),
202 extension_cache_task_runner_(extension_cache_task_runner), 205 extension_cache_task_runner_(extension_cache_task_runner),
203 request_context_(request_context), 206 request_context_(request_context),
204 local_accounts_subscription_(cros_settings_->AddSettingsObserver( 207 local_accounts_subscription_(cros_settings_->AddSettingsObserver(
205 chromeos::kAccountsPrefDeviceLocalAccounts, 208 chromeos::kAccountsPrefDeviceLocalAccounts,
206 base::Bind(&DeviceLocalAccountPolicyService:: 209 base::Bind(&DeviceLocalAccountPolicyService::
207 UpdateAccountListIfNonePending, 210 UpdateAccountListIfNonePending,
208 base::Unretained(this)))), 211 base::Unretained(this)))),
209 weak_factory_(this) { 212 weak_factory_(this) {
213 CHECK(PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_COMPONENT_POLICY,
214 &component_policy_cache_root_));
210 external_data_service_.reset(new DeviceLocalAccountExternalDataService( 215 external_data_service_.reset(new DeviceLocalAccountExternalDataService(
211 this, 216 this,
212 external_data_service_backend_task_runner, 217 external_data_service_backend_task_runner,
213 io_task_runner)); 218 io_task_runner));
214 UpdateAccountList(); 219 UpdateAccountList();
215 } 220 }
216 221
217 DeviceLocalAccountPolicyService::~DeviceLocalAccountPolicyService() { 222 DeviceLocalAccountPolicyService::~DeviceLocalAccountPolicyService() {
218 DCHECK(!request_context_); 223 DCHECK(!request_context_);
219 DCHECK(policy_brokers_.empty()); 224 DCHECK(policy_brokers_.empty());
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 session_manager_client_, 412 session_manager_client_,
408 device_settings_service_, 413 device_settings_service_,
409 store_background_task_runner_)); 414 store_background_task_runner_));
410 store->AddObserver(this); 415 store->AddObserver(this);
411 scoped_refptr<DeviceLocalAccountExternalDataManager> 416 scoped_refptr<DeviceLocalAccountExternalDataManager>
412 external_data_manager = 417 external_data_manager =
413 external_data_service_->GetExternalDataManager(it->account_id, 418 external_data_service_->GetExternalDataManager(it->account_id,
414 store.get()); 419 store.get());
415 broker.reset(new DeviceLocalAccountPolicyBroker( 420 broker.reset(new DeviceLocalAccountPolicyBroker(
416 *it, 421 *it,
422 component_policy_cache_root_.Append(EncodeAccountId(it->account_id)),
417 store.Pass(), 423 store.Pass(),
418 external_data_manager, 424 external_data_manager,
419 base::MessageLoopProxy::current())); 425 base::MessageLoopProxy::current()));
420 } 426 }
421 427
422 // Fire up the cloud connection for fetching policy for the account from 428 // Fire up the cloud connection for fetching policy for the account from
423 // the cloud if this is an enterprise-managed device. 429 // the cloud if this is an enterprise-managed device.
424 broker->ConnectIfPossible(device_settings_service_, 430 broker->ConnectIfPossible(device_settings_service_,
425 device_management_service_, 431 device_management_service_,
426 request_context_); 432 request_context_);
427 433
428 policy_brokers_[it->user_id] = broker.release(); 434 policy_brokers_[it->user_id] = broker.release();
429 if (!broker_initialized) { 435 if (!broker_initialized) {
430 // The broker must be initialized after it has been added to 436 // The broker must be initialized after it has been added to
431 // |policy_brokers_|. 437 // |policy_brokers_|.
432 policy_brokers_[it->user_id]->Initialize(); 438 policy_brokers_[it->user_id]->Initialize();
433 } 439 }
434 440
435 if (orphan_cache_deletion_state_ == NOT_STARTED) { 441 subdirectories_to_keep.insert(EncodeAccountId(it->account_id));
436 subdirectories_to_keep.insert(
437 GetCacheSubdirectoryForAccountID(it->account_id));
438 }
439 }
440
441 std::set<std::string> obsolete_account_ids;
442 for (PolicyBrokerMap::const_iterator it = old_policy_brokers.begin();
443 it != old_policy_brokers.end(); ++it) {
444 obsolete_account_ids.insert(it->second->account_id());
445 } 442 }
446 443
447 if (orphan_cache_deletion_state_ == NOT_STARTED) { 444 if (orphan_cache_deletion_state_ == NOT_STARTED) {
448 DCHECK(old_policy_brokers.empty()); 445 DCHECK(old_policy_brokers.empty());
449 DCHECK(busy_extension_cache_directories_.empty()); 446 DCHECK(busy_extension_cache_directories_.empty());
450 447
451 // If this method is running for the first time, no extension caches have 448 // If this method is running for the first time, no extension caches have
452 // been started yet. Take this opportunity to do a clean-up by removing 449 // been started yet. Take this opportunity to do a clean-up by removing
453 // orphaned cache directories not found in |subdirectories_to_keep| from the 450 // orphaned cache directories not found in |subdirectories_to_keep| from the
454 // cache directory. 451 // cache directory.
455 orphan_cache_deletion_state_ = IN_PROGRESS; 452 orphan_cache_deletion_state_ = IN_PROGRESS;
453
454 base::FilePath cache_root_dir;
455 CHECK(PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS,
Bernhard Bauer 2014/06/19 16:59:27 Why a CHECK instead of a DCHECK?
Joao da Silva 2014/06/19 17:04:56 Because this can't possibly fail, but if it does t
Bernhard Bauer 2014/06/19 17:22:44 Eh, "Can't possibly fail" is pretty much the defin
456 &cache_root_dir));
456 extension_cache_task_runner_->PostTaskAndReply( 457 extension_cache_task_runner_->PostTaskAndReply(
457 FROM_HERE, 458 FROM_HERE,
458 base::Bind(&DeleteOrphanedExtensionCaches, subdirectories_to_keep), 459 base::Bind(
459 base::Bind(&DeviceLocalAccountPolicyService:: 460 &DeleteOrphanedCaches, cache_root_dir, subdirectories_to_keep),
460 OnOrphanedExtensionCachesDeleted, 461 base::Bind(
461 weak_factory_.GetWeakPtr())); 462 &DeviceLocalAccountPolicyService::OnOrphanedExtensionCachesDeleted,
463 weak_factory_.GetWeakPtr()));
462 464
463 // Start the extension caches for all brokers. These belong to accounts in 465 // Start the extension caches for all brokers. These belong to accounts in
464 // |account_ids| and are not affected by the clean-up. 466 // |account_ids| and are not affected by the clean-up.
465 StartExtensionCachesIfPossible(); 467 StartExtensionCachesIfPossible();
466 } else { 468 } else {
467 // If this method has run before, obsolete brokers may exist. Shut down 469 // If this method has run before, obsolete brokers may exist. Shut down
468 // their extension caches and delete the brokers. 470 // their extension caches and delete the brokers.
469 DeleteBrokers(&old_policy_brokers); 471 DeleteBrokers(&old_policy_brokers);
470 472
471 if (orphan_cache_deletion_state_ == DONE) { 473 if (orphan_cache_deletion_state_ == DONE) {
472 // If the initial clean-up of orphaned cache directories has been 474 // If the initial clean-up of orphaned cache directories has been
473 // complete, start any extension caches that are not running yet but can 475 // complete, start any extension caches that are not running yet but can
474 // be started now because their cache directories are not busy. 476 // be started now because their cache directories are not busy.
475 StartExtensionCachesIfPossible(); 477 StartExtensionCachesIfPossible();
476 } 478 }
477 } 479 }
478 480
481 // Purge the component policy caches of any accounts that have been removed.
482 // Do this only after any obsolete brokers have been destroyed.
483 // TODO(joaodasilva): for now this must be posted to the FILE thread,
484 // to avoid racing with the ComponentCloudPolicyStore. Use a task runner
485 // once that class supports another background thread too.
486 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE,
487 base::Bind(&DeleteOrphanedCaches,
488 component_policy_cache_root_,
489 subdirectories_to_keep));
490
479 FOR_EACH_OBSERVER(Observer, observers_, OnDeviceLocalAccountsChanged()); 491 FOR_EACH_OBSERVER(Observer, observers_, OnDeviceLocalAccountsChanged());
480 } 492 }
481 493
482 void DeviceLocalAccountPolicyService::DeleteBrokers(PolicyBrokerMap* map) { 494 void DeviceLocalAccountPolicyService::DeleteBrokers(PolicyBrokerMap* map) {
483 for (PolicyBrokerMap::iterator it = map->begin(); it != map->end(); ++it) { 495 for (PolicyBrokerMap::iterator it = map->begin(); it != map->end(); ++it) {
484 it->second->core()->store()->RemoveObserver(this); 496 it->second->core()->store()->RemoveObserver(this);
485 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> 497 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader>
486 extension_loader = it->second->extension_loader(); 498 extension_loader = it->second->extension_loader();
487 if (extension_loader->IsCacheRunning()) { 499 if (extension_loader->IsCacheRunning()) {
488 DCHECK(!IsExtensionCacheDirectoryBusy(it->second->account_id())); 500 DCHECK(!IsExtensionCacheDirectoryBusy(it->second->account_id()));
489 busy_extension_cache_directories_.insert(it->second->account_id()); 501 busy_extension_cache_directories_.insert(it->second->account_id());
490 extension_loader->StopCache(base::Bind( 502 extension_loader->StopCache(base::Bind(
491 &DeviceLocalAccountPolicyService::OnObsoleteExtensionCacheShutdown, 503 &DeviceLocalAccountPolicyService::OnObsoleteExtensionCacheShutdown,
492 weak_factory_.GetWeakPtr(), 504 weak_factory_.GetWeakPtr(),
493 it->second->account_id())); 505 it->second->account_id()));
494 } 506 }
507 FOR_EACH_OBSERVER(Observer, observers_, OnBrokerShutdown(it->second));
495 delete it->second; 508 delete it->second;
496 } 509 }
497 map->clear(); 510 map->clear();
498 } 511 }
499 512
500 DeviceLocalAccountPolicyBroker* 513 DeviceLocalAccountPolicyBroker*
501 DeviceLocalAccountPolicyService::GetBrokerForStore( 514 DeviceLocalAccountPolicyService::GetBrokerForStore(
502 CloudPolicyStore* store) { 515 CloudPolicyStore* store) {
503 for (PolicyBrokerMap::iterator it(policy_brokers_.begin()); 516 for (PolicyBrokerMap::iterator it(policy_brokers_.begin());
504 it != policy_brokers_.end(); ++it) { 517 it != policy_brokers_.end(); ++it) {
505 if (it->second->core()->store() == store) 518 if (it->second->core()->store() == store)
506 return it->second; 519 return it->second;
507 } 520 }
508 return NULL; 521 return NULL;
509 } 522 }
510 523
511 } // namespace policy 524 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698