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

Side by Side Diff: third_party/WebKit/Source/core/dom/MainThreadTaskRunner.h

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 14 matching lines...) Expand all
25 */ 25 */
26 26
27 #ifndef MainThreadTaskRunner_h 27 #ifndef MainThreadTaskRunner_h
28 #define MainThreadTaskRunner_h 28 #define MainThreadTaskRunner_h
29 29
30 #include "core/CoreExport.h" 30 #include "core/CoreExport.h"
31 #include "platform/Timer.h" 31 #include "platform/Timer.h"
32 #include "platform/heap/Handle.h" 32 #include "platform/heap/Handle.h"
33 #include "wtf/Allocator.h" 33 #include "wtf/Allocator.h"
34 #include "wtf/Noncopyable.h" 34 #include "wtf/Noncopyable.h"
35 #include "wtf/PtrUtil.h"
36 #include "wtf/Vector.h" 35 #include "wtf/Vector.h"
37 #include "wtf/WeakPtr.h" 36 #include "wtf/WeakPtr.h"
38 #include <memory>
39 37
40 namespace blink { 38 namespace blink {
41 39
42 class ExecutionContext; 40 class ExecutionContext;
43 class ExecutionContextTask; 41 class ExecutionContextTask;
44 42
45 class CORE_EXPORT MainThreadTaskRunner final { 43 class CORE_EXPORT MainThreadTaskRunner final {
46 USING_FAST_MALLOC(MainThreadTaskRunner); 44 USING_FAST_MALLOC(MainThreadTaskRunner);
47 WTF_MAKE_NONCOPYABLE(MainThreadTaskRunner); 45 WTF_MAKE_NONCOPYABLE(MainThreadTaskRunner);
48 public: 46 public:
49 static std::unique_ptr<MainThreadTaskRunner> create(ExecutionContext*); 47 static PassOwnPtr<MainThreadTaskRunner> create(ExecutionContext*);
50 48
51 ~MainThreadTaskRunner(); 49 ~MainThreadTaskRunner();
52 50
53 DECLARE_TRACE(); 51 DECLARE_TRACE();
54 52
55 void postTask(const WebTraceLocation&, std::unique_ptr<ExecutionContextTask> ); // Executes the task on context's thread asynchronously. 53 void postTask(const WebTraceLocation&, std::unique_ptr<ExecutionContextTask> ); // Executes the task on context's thread asynchronously.
56 void postInspectorTask(const WebTraceLocation&, std::unique_ptr<ExecutionCon textTask>); 54 void postInspectorTask(const WebTraceLocation&, std::unique_ptr<ExecutionCon textTask>);
57 void perform(std::unique_ptr<ExecutionContextTask>, bool); 55 void perform(std::unique_ptr<ExecutionContextTask>, bool);
58 56
59 void suspend(); 57 void suspend();
60 void resume(); 58 void resume();
61 59
62 private: 60 private:
63 explicit MainThreadTaskRunner(ExecutionContext*); 61 explicit MainThreadTaskRunner(ExecutionContext*);
64 62
65 void pendingTasksTimerFired(Timer<MainThreadTaskRunner>*); 63 void pendingTasksTimerFired(Timer<MainThreadTaskRunner>*);
66 64
67 void postTaskInternal(const WebTraceLocation&, std::unique_ptr<ExecutionCont extTask>, bool isInspectorTask); 65 void postTaskInternal(const WebTraceLocation&, std::unique_ptr<ExecutionCont extTask>, bool isInspectorTask);
68 66
69 // Untraced back reference to the owner Document; 67 // Untraced back reference to the owner Document;
70 // this object has identical lifetime to it. 68 // this object has identical lifetime to it.
71 UntracedMember<ExecutionContext> m_context; 69 UntracedMember<ExecutionContext> m_context;
72 Timer<MainThreadTaskRunner> m_pendingTasksTimer; 70 Timer<MainThreadTaskRunner> m_pendingTasksTimer;
73 Vector<std::unique_ptr<ExecutionContextTask>> m_pendingTasks; 71 Vector<std::unique_ptr<ExecutionContextTask>> m_pendingTasks;
74 bool m_suspended; 72 bool m_suspended;
75 WeakPtrFactory<MainThreadTaskRunner> m_weakFactory; 73 WeakPtrFactory<MainThreadTaskRunner> m_weakFactory;
76 }; 74 };
77 75
78 inline std::unique_ptr<MainThreadTaskRunner> MainThreadTaskRunner::create(Execut ionContext* context) 76 inline PassOwnPtr<MainThreadTaskRunner> MainThreadTaskRunner::create(ExecutionCo ntext* context)
79 { 77 {
80 return wrapUnique(new MainThreadTaskRunner(context)); 78 return adoptPtr(new MainThreadTaskRunner(context));
81 } 79 }
82 80
83 } // namespace blink 81 } // namespace blink
84 82
85 #endif 83 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698