interceptable_pref_filter.cc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "services/preferences/tracked/interceptable_pref_filter.h"
  5. #include <utility>
  6. #include "base/bind.h"
  7. InterceptablePrefFilter::InterceptablePrefFilter() {}
  8. InterceptablePrefFilter::~InterceptablePrefFilter() {}
  9. void InterceptablePrefFilter::FilterOnLoad(
  10. PostFilterOnLoadCallback post_filter_on_load_callback,
  11. std::unique_ptr<base::DictionaryValue> pref_store_contents) {
  12. if (filter_on_load_interceptor_.is_null()) {
  13. FinalizeFilterOnLoad(std::move(post_filter_on_load_callback),
  14. std::move(pref_store_contents), false);
  15. } else {
  16. // Note, in practice (in the implementation as it was in May 2014) it would
  17. // be okay to pass an unretained |this| pointer below, but in order to avoid
  18. // having to augment the API everywhere to explicitly enforce the ownership
  19. // model as it happens to currently be: make the relationship simpler by
  20. // weakly binding the FinalizeFilterOnLoadCallback below to |this|.
  21. FinalizeFilterOnLoadCallback finalize_filter_on_load(
  22. base::BindOnce(&InterceptablePrefFilter::FinalizeFilterOnLoad,
  23. AsWeakPtr(), std::move(post_filter_on_load_callback)));
  24. std::move(filter_on_load_interceptor_)
  25. .Run(std::move(finalize_filter_on_load),
  26. std::move(pref_store_contents));
  27. }
  28. }
  29. void InterceptablePrefFilter::InterceptNextFilterOnLoad(
  30. FilterOnLoadInterceptor filter_on_load_interceptor) {
  31. DCHECK(filter_on_load_interceptor_.is_null());
  32. filter_on_load_interceptor_ = std::move(filter_on_load_interceptor);
  33. }
  34. void InterceptablePrefFilter::OnStoreDeletionFromDisk() {}