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

Unified Diff: chrome/browser/prefs/interceptable_pref_filter.cc

Issue 257003007: Introduce a new framework for back-and-forth tracked/protected preferences migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment nit Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/prefs/interceptable_pref_filter.h ('k') | chrome/browser/prefs/pref_hash_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/interceptable_pref_filter.cc
diff --git a/chrome/browser/prefs/interceptable_pref_filter.cc b/chrome/browser/prefs/interceptable_pref_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b04c07ddf54dbc473290976b15e1544b7b9bb8fd
--- /dev/null
+++ b/chrome/browser/prefs/interceptable_pref_filter.cc
@@ -0,0 +1,39 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/prefs/interceptable_pref_filter.h"
+
+#include "base/bind.h"
+
+InterceptablePrefFilter::InterceptablePrefFilter() {}
+InterceptablePrefFilter::~InterceptablePrefFilter() {}
+
+void InterceptablePrefFilter::FilterOnLoad(
+ const PostFilterOnLoadCallback& post_filter_on_load_callback,
+ scoped_ptr<base::DictionaryValue> pref_store_contents) {
+ if (filter_on_load_interceptor_.is_null()) {
+ FinalizeFilterOnLoad(post_filter_on_load_callback,
+ pref_store_contents.Pass(),
+ false);
+ } else {
+ // Note, in practice (in the implementation as it was in May 2014) it would
+ // be okay to pass an unretained |this| pointer below, but in order to avoid
+ // having to augment the API everywhere to explicitly enforce the ownership
+ // model as it happens to currently be: make the relationship simpler by
+ // weakly binding the FinalizeFilterOnLoadCallback below to |this|.
+ const FinalizeFilterOnLoadCallback finalize_filter_on_load(
+ base::Bind(&InterceptablePrefFilter::FinalizeFilterOnLoad,
+ AsWeakPtr(),
+ post_filter_on_load_callback));
+ filter_on_load_interceptor_.Run(finalize_filter_on_load,
+ pref_store_contents.Pass());
+ filter_on_load_interceptor_.Reset();
+ }
+}
+
+void InterceptablePrefFilter::InterceptNextFilterOnLoad(
+ const FilterOnLoadInterceptor& filter_on_load_interceptor) {
+ DCHECK(filter_on_load_interceptor_.is_null());
+ filter_on_load_interceptor_ = filter_on_load_interceptor;
+}
« no previous file with comments | « chrome/browser/prefs/interceptable_pref_filter.h ('k') | chrome/browser/prefs/pref_hash_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698