OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/user_prefs/tracked/interceptable_pref_filter.h" | 5 #include "components/user_prefs/tracked/interceptable_pref_filter.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 | 10 |
9 InterceptablePrefFilter::InterceptablePrefFilter() { | 11 InterceptablePrefFilter::InterceptablePrefFilter() { |
10 } | 12 } |
11 InterceptablePrefFilter::~InterceptablePrefFilter() { | 13 InterceptablePrefFilter::~InterceptablePrefFilter() { |
12 } | 14 } |
13 | 15 |
14 void InterceptablePrefFilter::FilterOnLoad( | 16 void InterceptablePrefFilter::FilterOnLoad( |
15 const PostFilterOnLoadCallback& post_filter_on_load_callback, | 17 const PostFilterOnLoadCallback& post_filter_on_load_callback, |
16 scoped_ptr<base::DictionaryValue> pref_store_contents) { | 18 scoped_ptr<base::DictionaryValue> pref_store_contents) { |
17 if (filter_on_load_interceptor_.is_null()) { | 19 if (filter_on_load_interceptor_.is_null()) { |
18 FinalizeFilterOnLoad(post_filter_on_load_callback, | 20 FinalizeFilterOnLoad(post_filter_on_load_callback, |
19 pref_store_contents.Pass(), false); | 21 std::move(pref_store_contents), false); |
20 } else { | 22 } else { |
21 // Note, in practice (in the implementation as it was in May 2014) it would | 23 // Note, in practice (in the implementation as it was in May 2014) it would |
22 // be okay to pass an unretained |this| pointer below, but in order to avoid | 24 // be okay to pass an unretained |this| pointer below, but in order to avoid |
23 // having to augment the API everywhere to explicitly enforce the ownership | 25 // having to augment the API everywhere to explicitly enforce the ownership |
24 // model as it happens to currently be: make the relationship simpler by | 26 // model as it happens to currently be: make the relationship simpler by |
25 // weakly binding the FinalizeFilterOnLoadCallback below to |this|. | 27 // weakly binding the FinalizeFilterOnLoadCallback below to |this|. |
26 const FinalizeFilterOnLoadCallback finalize_filter_on_load( | 28 const FinalizeFilterOnLoadCallback finalize_filter_on_load( |
27 base::Bind(&InterceptablePrefFilter::FinalizeFilterOnLoad, AsWeakPtr(), | 29 base::Bind(&InterceptablePrefFilter::FinalizeFilterOnLoad, AsWeakPtr(), |
28 post_filter_on_load_callback)); | 30 post_filter_on_load_callback)); |
29 filter_on_load_interceptor_.Run(finalize_filter_on_load, | 31 filter_on_load_interceptor_.Run(finalize_filter_on_load, |
30 pref_store_contents.Pass()); | 32 std::move(pref_store_contents)); |
31 filter_on_load_interceptor_.Reset(); | 33 filter_on_load_interceptor_.Reset(); |
32 } | 34 } |
33 } | 35 } |
34 | 36 |
35 void InterceptablePrefFilter::InterceptNextFilterOnLoad( | 37 void InterceptablePrefFilter::InterceptNextFilterOnLoad( |
36 const FilterOnLoadInterceptor& filter_on_load_interceptor) { | 38 const FilterOnLoadInterceptor& filter_on_load_interceptor) { |
37 DCHECK(filter_on_load_interceptor_.is_null()); | 39 DCHECK(filter_on_load_interceptor_.is_null()); |
38 filter_on_load_interceptor_ = filter_on_load_interceptor; | 40 filter_on_load_interceptor_ = filter_on_load_interceptor; |
39 } | 41 } |
OLD | NEW |