OLD | NEW |
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 #ifndef STORAGE_BROWSER_FILEAPI_TASK_RUNNER_BOUND_OBSERVER_LIST_H_ | 5 #ifndef STORAGE_BROWSER_FILEAPI_TASK_RUNNER_BOUND_OBSERVER_LIST_H_ |
6 #define STORAGE_BROWSER_FILEAPI_TASK_RUNNER_BOUND_OBSERVER_LIST_H_ | 6 #define STORAGE_BROWSER_FILEAPI_TASK_RUNNER_BOUND_OBSERVER_LIST_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 // Notify on the task runner that is given to AddObserver. | 63 // Notify on the task runner that is given to AddObserver. |
64 // If we're already on the runner this just dispatches the method. | 64 // If we're already on the runner this just dispatches the method. |
65 template <class Method, class Params> | 65 template <class Method, class Params> |
66 void Notify(Method method, const Params& params) const { | 66 void Notify(Method method, const Params& params) const { |
67 static_assert( | 67 static_assert( |
68 (base::internal::ParamsUseScopedRefptrCorrectly<Params>::value), | 68 (base::internal::ParamsUseScopedRefptrCorrectly<Params>::value), |
69 "bad unbound method params"); | 69 "bad unbound method params"); |
70 for (typename ObserversListMap::const_iterator it = observers_.begin(); | 70 for (typename ObserversListMap::const_iterator it = observers_.begin(); |
71 it != observers_.end(); ++it) { | 71 it != observers_.end(); ++it) { |
72 if (!it->second.get() || it->second->RunsTasksOnCurrentThread()) { | 72 if (!it->second.get() || it->second->RunsTasksInCurrentSequence()) { |
73 base::DispatchToMethod(it->first, method, params); | 73 base::DispatchToMethod(it->first, method, params); |
74 continue; | 74 continue; |
75 } | 75 } |
76 it->second->PostTask( | 76 it->second->PostTask( |
77 FROM_HERE, | 77 FROM_HERE, |
78 base::Bind(&NotifyWrapper<ObserverStoreType, Method, Params>, | 78 base::Bind(&NotifyWrapper<ObserverStoreType, Method, Params>, |
79 it->first, method, params)); | 79 it->first, method, params)); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 private: | 83 private: |
84 ObserversListMap observers_; | 84 ObserversListMap observers_; |
85 }; | 85 }; |
86 | 86 |
87 class FileAccessObserver; | 87 class FileAccessObserver; |
88 class FileChangeObserver; | 88 class FileChangeObserver; |
89 class FileUpdateObserver; | 89 class FileUpdateObserver; |
90 | 90 |
91 typedef TaskRunnerBoundObserverList<FileAccessObserver> AccessObserverList; | 91 typedef TaskRunnerBoundObserverList<FileAccessObserver> AccessObserverList; |
92 typedef TaskRunnerBoundObserverList<FileChangeObserver> ChangeObserverList; | 92 typedef TaskRunnerBoundObserverList<FileChangeObserver> ChangeObserverList; |
93 typedef TaskRunnerBoundObserverList<FileUpdateObserver> UpdateObserverList; | 93 typedef TaskRunnerBoundObserverList<FileUpdateObserver> UpdateObserverList; |
94 | 94 |
95 } // namespace storage | 95 } // namespace storage |
96 | 96 |
97 #endif // STORAGE_BROWSER_FILEAPI_TASK_RUNNER_BOUND_OBSERVER_LIST_H_ | 97 #endif // STORAGE_BROWSER_FILEAPI_TASK_RUNNER_BOUND_OBSERVER_LIST_H_ |
OLD | NEW |