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

Side by Side Diff: chrome/browser/policy/cloud/user_cloud_policy_manager.cc

Issue 98433003: Fixed crash in CloudPolicyManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build Created 7 years 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/cloud/user_cloud_policy_manager.h" 5 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.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/sequenced_task_runner.h" 9 #include "base/sequenced_task_runner.h"
10 #include "chrome/browser/policy/cloud/cloud_external_data_manager.h" 10 #include "chrome/browser/policy/cloud/cloud_external_data_manager.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 void UserCloudPolicyManager::Connect( 59 void UserCloudPolicyManager::Connect(
60 PrefService* local_state, 60 PrefService* local_state,
61 scoped_refptr<net::URLRequestContextGetter> request_context, 61 scoped_refptr<net::URLRequestContextGetter> request_context,
62 scoped_ptr<CloudPolicyClient> client) { 62 scoped_ptr<CloudPolicyClient> client) {
63 core()->Connect(client.Pass()); 63 core()->Connect(client.Pass());
64 core()->StartRefreshScheduler(); 64 core()->StartRefreshScheduler();
65 core()->TrackRefreshDelayPref(local_state, 65 core()->TrackRefreshDelayPref(local_state,
66 policy_prefs::kUserPolicyRefreshRate); 66 policy_prefs::kUserPolicyRefreshRate);
67 if (external_data_manager_) 67 if (external_data_manager_)
68 external_data_manager_->Connect(request_context); 68 external_data_manager_->Connect(request_context);
69
69 CreateComponentCloudPolicyService(component_policy_cache_path_, 70 CreateComponentCloudPolicyService(component_policy_cache_path_,
70 request_context); 71 request_context);
71 } 72 }
72 73
73 // static 74 // static
74 scoped_ptr<CloudPolicyClient> 75 scoped_ptr<CloudPolicyClient>
75 UserCloudPolicyManager::CreateCloudPolicyClient( 76 UserCloudPolicyManager::CreateCloudPolicyClient(
76 DeviceManagementService* device_management_service) { 77 DeviceManagementService* device_management_service) {
77 return make_scoped_ptr( 78 return make_scoped_ptr(
78 new CloudPolicyClient(std::string(), std::string(), 79 new CloudPolicyClient(std::string(), std::string(),
79 USER_AFFILIATION_NONE, 80 USER_AFFILIATION_NONE,
80 NULL, device_management_service)).Pass(); 81 NULL, device_management_service)).Pass();
81 } 82 }
82 83
83 void UserCloudPolicyManager::DisconnectAndRemovePolicy() { 84 void UserCloudPolicyManager::DisconnectAndRemovePolicy() {
84 if (external_data_manager_) 85 if (external_data_manager_)
85 external_data_manager_->Disconnect(); 86 external_data_manager_->Disconnect();
86 core()->Disconnect(); 87 core()->Disconnect();
88
89 // store_->Clear() will publish the updated, empty policy. The component
90 // policy service must be cleared before OnStoreLoaded() is issued, so that
91 // component policies are also empty at CheckAndPublishPolicy().
92 ClearAndDestroyComponentCloudPolicyService();
93
87 // When the |store_| is cleared, it informs the |external_data_manager_| that 94 // When the |store_| is cleared, it informs the |external_data_manager_| that
88 // all external data references have been removed, causing the 95 // all external data references have been removed, causing the
89 // |external_data_manager_| to clear its cache as well. 96 // |external_data_manager_| to clear its cache as well.
90 store_->Clear(); 97 store_->Clear();
91 } 98 }
92 99
93 bool UserCloudPolicyManager::IsClientRegistered() const { 100 bool UserCloudPolicyManager::IsClientRegistered() const {
94 return client() && client()->is_registered(); 101 return client() && client()->is_registered();
95 } 102 }
96 103
97 } // namespace policy 104 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698