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

Side by Side Diff: components/subresource_filter/core/browser/ruleset_service.cc

Issue 2731283009: Swap ownership of RulesetService and the content delegate (Closed)
Patch Set: Swap ownership of RulesetService and the content delegate Created 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/subresource_filter/core/browser/ruleset_service.h" 5 #include "components/subresource_filter/core/browser/ruleset_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 decltype(&RulesetService::IndexRuleset) RulesetService::g_index_ruleset_func = 208 decltype(&RulesetService::IndexRuleset) RulesetService::g_index_ruleset_func =
209 &RulesetService::IndexRuleset; 209 &RulesetService::IndexRuleset;
210 210
211 // static 211 // static
212 decltype(&base::ReplaceFile) RulesetService::g_replace_file_func = 212 decltype(&base::ReplaceFile) RulesetService::g_replace_file_func =
213 &base::ReplaceFile; 213 &base::ReplaceFile;
214 214
215 RulesetService::RulesetService( 215 RulesetService::RulesetService(
216 PrefService* local_state, 216 PrefService* local_state,
217 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, 217 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
218 std::unique_ptr<RulesetServiceDelegate> delegate, 218 RulesetServiceDelegate* delegate,
219 const base::FilePath& indexed_ruleset_base_dir) 219 const base::FilePath& indexed_ruleset_base_dir)
220 : local_state_(local_state), 220 : local_state_(local_state),
221 blocking_task_runner_(blocking_task_runner), 221 blocking_task_runner_(blocking_task_runner),
222 delegate_(std::move(delegate)), 222 delegate_(delegate),
223 is_after_startup_(false), 223 is_after_startup_(false),
224 indexed_ruleset_base_dir_(indexed_ruleset_base_dir) { 224 indexed_ruleset_base_dir_(indexed_ruleset_base_dir) {
225 DCHECK(delegate_); 225 DCHECK(delegate_);
226 DCHECK_NE(local_state_->GetInitializationStatus(), 226 DCHECK_NE(local_state_->GetInitializationStatus(),
227 PrefService::INITIALIZATION_STATUS_WAITING); 227 PrefService::INITIALIZATION_STATUS_WAITING);
228 228
229 IndexedRulesetVersion most_recently_indexed_version; 229 IndexedRulesetVersion most_recently_indexed_version;
230 most_recently_indexed_version.ReadFromPrefs(local_state_); 230 most_recently_indexed_version.ReadFromPrefs(local_state_);
231 if (most_recently_indexed_version.IsValid() && 231 if (most_recently_indexed_version.IsValid() &&
232 most_recently_indexed_version.IsCurrentFormatVersion()) { 232 most_recently_indexed_version.IsCurrentFormatVersion()) {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // version. Bail out. 498 // version. Bail out.
499 DCHECK(ruleset_data_); 499 DCHECK(ruleset_data_);
500 if (!ruleset_data_->IsValid()) 500 if (!ruleset_data_->IsValid())
501 return; 501 return;
502 502
503 DCHECK_EQ(error, base::File::Error::FILE_OK); 503 DCHECK_EQ(error, base::File::Error::FILE_OK);
504 delegate_->PublishNewRulesetVersion(ruleset_data_->DuplicateFile()); 504 delegate_->PublishNewRulesetVersion(ruleset_data_->DuplicateFile());
505 } 505 }
506 506
507 } // namespace subresource_filter 507 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698