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

Side by Side Diff: Source/platform/scheduler/CancellableTaskFactory.h

Issue 876623002: Adds a CancellableTaskFactory and exposes postLoadingTasks to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2015 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
5 #ifndef CancellableTaskFactory_h
6 #define CancellableTaskFactory_h
7
8 #include "platform/PlatformExport.h"
9 #include "public/platform/WebScheduler.h"
10 #include "wtf/Functional.h"
11 #include "wtf/Noncopyable.h"
12 #include "wtf/OwnPtr.h"
13 #include "wtf/PassOwnPtr.h"
14 #include "wtf/RefCounted.h"
15 #include "wtf/WeakPtr.h"
16
17 namespace blink {
18 class TraceLocation;
19
20 class PLATFORM_EXPORT CancellableTaskFactory {
21 WTF_MAKE_NONCOPYABLE(CancellableTaskFactory);
22 public:
23 explicit CancellableTaskFactory(PassOwnPtr<Closure> closure) : m_closure(clo sure), m_weakPtrFactory(this) { }
24
25 bool isPending() const
26 {
27 return m_weakPtrFactory.hasWeakPtrs();
28 }
29
30 void cancel();
31
32 // Returns a task that can be disabled by calling cancel(). The user takes
33 // ownership of the task. Creating a new task cancels any previous ones.
34 WebThread::Task* task();
35
36 private:
37 class CancellableTask : public WebThread::Task {
38 public:
jochen (gone - plz use gerrit) 2015/01/26 15:53:31 nit. also make this non copyable
alex clarke (OOO till 29th) 2015/01/26 17:00:45 Done.
39 explicit CancellableTask(WeakPtr<CancellableTaskFactory> weakPtr) : m_we akPtr(weakPtr) { }
Sami 2015/01/26 16:08:14 nit: Something like |factory| would be a little mo
40 virtual ~CancellableTask() { }
41
42 void run() override;
43
44 private:
45 WeakPtr<CancellableTaskFactory> m_weakPtr;
46 };
47
48 void runInternal();
49
50 OwnPtr<Closure> m_closure;
51 WeakPtrFactory<CancellableTaskFactory> m_weakPtrFactory;
52
53 friend class CancellableTask;
54 };
55
56 } // namespace blink
57
58 #endif // CancellableTaskFactory_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698