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

Side by Side Diff: storage/browser/fileapi/task_runner_bound_observer_list.h

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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 WEBKIT_BROWSER_FILEAPI_TASK_RUNNER_BOUND_OBSERVER_LIST_H_ 5 #ifndef WEBKIT_BROWSER_FILEAPI_TASK_RUNNER_BOUND_OBSERVER_LIST_H_
6 #define WEBKIT_BROWSER_FILEAPI_TASK_RUNNER_BOUND_OBSERVER_LIST_H_ 6 #define WEBKIT_BROWSER_FILEAPI_TASK_RUNNER_BOUND_OBSERVER_LIST_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 15
16 namespace fileapi { 16 namespace storage {
17 17
18 // A wrapper for dispatching method. 18 // A wrapper for dispatching method.
19 template <class T, class Method, class Params> 19 template <class T, class Method, class Params>
20 void NotifyWrapper(T obj, Method m, const Params& p) { 20 void NotifyWrapper(T obj, Method m, const Params& p) {
21 DispatchToMethod(base::internal::UnwrapTraits<T>::Unwrap(obj), m, p); 21 DispatchToMethod(base::internal::UnwrapTraits<T>::Unwrap(obj), m, p);
22 } 22 }
23 23
24 // An observer list helper to notify on a given task runner. 24 // An observer list helper to notify on a given task runner.
25 // Observer pointers (stored as ObserverStoreType) must be kept alive 25 // Observer pointers (stored as ObserverStoreType) must be kept alive
26 // until this list dispatches all the notifications. 26 // until this list dispatches all the notifications.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
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 COMPILE_ASSERT( 67 COMPILE_ASSERT(
68 (base::internal::ParamsUseScopedRefptrCorrectly<Params>::value), 68 (base::internal::ParamsUseScopedRefptrCorrectly<Params>::value),
69 badunboundmethodparams); 69 badunboundmethodparams);
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();
72 ++it) {
72 if (!it->second.get() || it->second->RunsTasksOnCurrentThread()) { 73 if (!it->second.get() || it->second->RunsTasksOnCurrentThread()) {
73 DispatchToMethod(UnwrapTraits::Unwrap(it->first), method, params); 74 DispatchToMethod(UnwrapTraits::Unwrap(it->first), method, params);
74 continue; 75 continue;
75 } 76 }
76 it->second->PostTask( 77 it->second->PostTask(
77 FROM_HERE, 78 FROM_HERE,
78 base::Bind(&NotifyWrapper<ObserverStoreType, Method, Params>, 79 base::Bind(&NotifyWrapper<ObserverStoreType, Method, Params>,
79 it->first, method, params)); 80 it->first,
81 method,
82 params));
80 } 83 }
81 } 84 }
82 85
83 private: 86 private:
84 typedef base::internal::UnwrapTraits<ObserverStoreType> UnwrapTraits; 87 typedef base::internal::UnwrapTraits<ObserverStoreType> UnwrapTraits;
85 88
86 ObserversListMap observers_; 89 ObserversListMap observers_;
87 }; 90 };
88 91
89 class FileAccessObserver; 92 class FileAccessObserver;
90 class FileChangeObserver; 93 class FileChangeObserver;
91 class FileUpdateObserver; 94 class FileUpdateObserver;
92 95
93 typedef TaskRunnerBoundObserverList<FileAccessObserver> AccessObserverList; 96 typedef TaskRunnerBoundObserverList<FileAccessObserver> AccessObserverList;
94 typedef TaskRunnerBoundObserverList<FileChangeObserver> ChangeObserverList; 97 typedef TaskRunnerBoundObserverList<FileChangeObserver> ChangeObserverList;
95 typedef TaskRunnerBoundObserverList<FileUpdateObserver> UpdateObserverList; 98 typedef TaskRunnerBoundObserverList<FileUpdateObserver> UpdateObserverList;
96 99
97 } // namespace fileapi 100 } // namespace storage
98 101
99 #endif // WEBKIT_BROWSER_FILEAPI_TASK_RUNNER_BOUND_OBSERVER_LIST_H_ 102 #endif // WEBKIT_BROWSER_FILEAPI_TASK_RUNNER_BOUND_OBSERVER_LIST_H_
OLDNEW
« no previous file with comments | « storage/browser/fileapi/sandbox_quota_observer.cc ('k') | storage/browser/fileapi/timed_task_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698