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

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

Issue 572873002: Declaring the weak_ptr_factory in proper order. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build break fixed Created 6 years, 3 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/chromeos/policy/user_cloud_policy_store_chromeos.h" 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.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/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 private: 86 private:
87 // Checks whether the load operations from the legacy caches completed. If so, 87 // Checks whether the load operations from the legacy caches completed. If so,
88 // fires the appropriate notification. 88 // fires the appropriate notification.
89 void CheckLoadFinished(); 89 void CheckLoadFinished();
90 90
91 // Maps a disk cache LoadResult to a CloudPolicyStore::Status. 91 // Maps a disk cache LoadResult to a CloudPolicyStore::Status.
92 static CloudPolicyStore::Status TranslateLoadResult( 92 static CloudPolicyStore::Status TranslateLoadResult(
93 UserPolicyDiskCache::LoadResult result); 93 UserPolicyDiskCache::LoadResult result);
94 94
95 base::WeakPtrFactory<LegacyPolicyCacheLoader> weak_factory_;
96
97 scoped_refptr<UserPolicyTokenLoader> token_loader_; 95 scoped_refptr<UserPolicyTokenLoader> token_loader_;
98 scoped_refptr<UserPolicyDiskCache> policy_cache_; 96 scoped_refptr<UserPolicyDiskCache> policy_cache_;
99 97
100 std::string dm_token_; 98 std::string dm_token_;
101 std::string device_id_; 99 std::string device_id_;
102 bool has_policy_; 100 bool has_policy_;
103 scoped_ptr<em::PolicyFetchResponse> policy_; 101 scoped_ptr<em::PolicyFetchResponse> policy_;
104 CloudPolicyStore::Status status_; 102 CloudPolicyStore::Status status_;
105 103
106 Callback callback_; 104 Callback callback_;
107 105
106 base::WeakPtrFactory<LegacyPolicyCacheLoader> weak_factory_;
107
108 DISALLOW_COPY_AND_ASSIGN(LegacyPolicyCacheLoader); 108 DISALLOW_COPY_AND_ASSIGN(LegacyPolicyCacheLoader);
109 }; 109 };
110 110
111 LegacyPolicyCacheLoader::LegacyPolicyCacheLoader( 111 LegacyPolicyCacheLoader::LegacyPolicyCacheLoader(
112 const base::FilePath& token_cache_file, 112 const base::FilePath& token_cache_file,
113 const base::FilePath& policy_cache_file, 113 const base::FilePath& policy_cache_file,
114 scoped_refptr<base::SequencedTaskRunner> background_task_runner) 114 scoped_refptr<base::SequencedTaskRunner> background_task_runner)
115 : weak_factory_(this), 115 : has_policy_(false),
116 has_policy_(false), 116 status_(CloudPolicyStore::STATUS_OK),
117 status_(CloudPolicyStore::STATUS_OK) { 117 weak_factory_(this) {
118 token_loader_ = new UserPolicyTokenLoader(weak_factory_.GetWeakPtr(), 118 token_loader_ = new UserPolicyTokenLoader(weak_factory_.GetWeakPtr(),
119 token_cache_file, 119 token_cache_file,
120 background_task_runner); 120 background_task_runner);
121 policy_cache_ = new UserPolicyDiskCache(weak_factory_.GetWeakPtr(), 121 policy_cache_ = new UserPolicyDiskCache(weak_factory_.GetWeakPtr(),
122 policy_cache_file, 122 policy_cache_file,
123 background_task_runner); 123 background_task_runner);
124 } 124 }
125 125
126 LegacyPolicyCacheLoader::~LegacyPolicyCacheLoader() {} 126 LegacyPolicyCacheLoader::~LegacyPolicyCacheLoader() {}
127 127
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 scoped_refptr<base::SequencedTaskRunner> background_task_runner, 179 scoped_refptr<base::SequencedTaskRunner> background_task_runner,
180 const std::string& username, 180 const std::string& username,
181 const base::FilePath& user_policy_key_dir, 181 const base::FilePath& user_policy_key_dir,
182 const base::FilePath& legacy_token_cache_file, 182 const base::FilePath& legacy_token_cache_file,
183 const base::FilePath& legacy_policy_cache_file) 183 const base::FilePath& legacy_policy_cache_file)
184 : UserCloudPolicyStoreBase(background_task_runner), 184 : UserCloudPolicyStoreBase(background_task_runner),
185 cryptohome_client_(cryptohome_client), 185 cryptohome_client_(cryptohome_client),
186 session_manager_client_(session_manager_client), 186 session_manager_client_(session_manager_client),
187 username_(username), 187 username_(username),
188 user_policy_key_dir_(user_policy_key_dir), 188 user_policy_key_dir_(user_policy_key_dir),
189 weak_factory_(this),
190 legacy_cache_dir_(legacy_token_cache_file.DirName()), 189 legacy_cache_dir_(legacy_token_cache_file.DirName()),
191 legacy_loader_(new LegacyPolicyCacheLoader(legacy_token_cache_file, 190 legacy_loader_(new LegacyPolicyCacheLoader(legacy_token_cache_file,
192 legacy_policy_cache_file, 191 legacy_policy_cache_file,
193 background_task_runner)), 192 background_task_runner)),
194 legacy_caches_loaded_(false), 193 legacy_caches_loaded_(false),
195 policy_key_loaded_(false) {} 194 policy_key_loaded_(false),
195 weak_factory_(this) {}
196 196
197 UserCloudPolicyStoreChromeOS::~UserCloudPolicyStoreChromeOS() {} 197 UserCloudPolicyStoreChromeOS::~UserCloudPolicyStoreChromeOS() {}
198 198
199 void UserCloudPolicyStoreChromeOS::Store( 199 void UserCloudPolicyStoreChromeOS::Store(
200 const em::PolicyFetchResponse& policy) { 200 const em::PolicyFetchResponse& policy) {
201 // Cancel all pending requests. 201 // Cancel all pending requests.
202 weak_factory_.InvalidateWeakPtrs(); 202 weak_factory_.InvalidateWeakPtrs();
203 scoped_ptr<em::PolicyFetchResponse> response( 203 scoped_ptr<em::PolicyFetchResponse> response(
204 new em::PolicyFetchResponse(policy)); 204 new em::PolicyFetchResponse(policy));
205 EnsurePolicyKeyLoaded( 205 EnsurePolicyKeyLoaded(
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 const std::string empty_key = std::string(); 562 const std::string empty_key = std::string();
563 // The policy loaded from session manager need not be validated using the 563 // The policy loaded from session manager need not be validated using the
564 // verification key since it is secure, and since there may be legacy policy 564 // verification key since it is secure, and since there may be legacy policy
565 // data that was stored without a verification key. Hence passing an empty 565 // data that was stored without a verification key. Hence passing an empty
566 // value for the verification key. 566 // value for the verification key.
567 validator->ValidateSignature( 567 validator->ValidateSignature(
568 policy_key_, empty_key, ExtractDomain(username_), allow_rotation); 568 policy_key_, empty_key, ExtractDomain(username_), allow_rotation);
569 return validator.Pass(); 569 return validator.Pass();
570 } 570 }
571 } // namespace policy 571 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698