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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. 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"
35 #include "wtf/Vector.h" 36 #include "wtf/Vector.h"
36 #include "wtf/WeakPtr.h" 37 #include "wtf/WeakPtr.h"
38 #include <memory>
37 39
38 namespace blink { 40 namespace blink {
39 41
40 class ExecutionContext; 42 class ExecutionContext;
41 class ExecutionContextTask; 43 class ExecutionContextTask;
42 44
43 class CORE_EXPORT MainThreadTaskRunner final { 45 class CORE_EXPORT MainThreadTaskRunner final {
44 USING_FAST_MALLOC(MainThreadTaskRunner); 46 USING_FAST_MALLOC(MainThreadTaskRunner);
45 WTF_MAKE_NONCOPYABLE(MainThreadTaskRunner); 47 WTF_MAKE_NONCOPYABLE(MainThreadTaskRunner);
46 public: 48 public:
47 static PassOwnPtr<MainThreadTaskRunner> create(ExecutionContext*); 49 static std::unique_ptr<MainThreadTaskRunner> create(ExecutionContext*);
48 50
49 ~MainThreadTaskRunner(); 51 ~MainThreadTaskRunner();
50 52
51 DECLARE_TRACE(); 53 DECLARE_TRACE();
52 54
53 void postTask(const WebTraceLocation&, std::unique_ptr<ExecutionContextTask> ); // Executes the task on context's thread asynchronously. 55 void postTask(const WebTraceLocation&, std::unique_ptr<ExecutionContextTask> ); // Executes the task on context's thread asynchronously.
54 void postInspectorTask(const WebTraceLocation&, std::unique_ptr<ExecutionCon textTask>); 56 void postInspectorTask(const WebTraceLocation&, std::unique_ptr<ExecutionCon textTask>);
55 void perform(std::unique_ptr<ExecutionContextTask>, bool); 57 void perform(std::unique_ptr<ExecutionContextTask>, bool);
56 58
57 void suspend(); 59 void suspend();
58 void resume(); 60 void resume();
59 61
60 private: 62 private:
61 explicit MainThreadTaskRunner(ExecutionContext*); 63 explicit MainThreadTaskRunner(ExecutionContext*);
62 64
63 void pendingTasksTimerFired(Timer<MainThreadTaskRunner>*); 65 void pendingTasksTimerFired(Timer<MainThreadTaskRunner>*);
64 66
65 void postTaskInternal(const WebTraceLocation&, std::unique_ptr<ExecutionCont extTask>, bool isInspectorTask); 67 void postTaskInternal(const WebTraceLocation&, std::unique_ptr<ExecutionCont extTask>, bool isInspectorTask);
66 68
67 // Untraced back reference to the owner Document; 69 // Untraced back reference to the owner Document;
68 // this object has identical lifetime to it. 70 // this object has identical lifetime to it.
69 UntracedMember<ExecutionContext> m_context; 71 UntracedMember<ExecutionContext> m_context;
70 Timer<MainThreadTaskRunner> m_pendingTasksTimer; 72 Timer<MainThreadTaskRunner> m_pendingTasksTimer;
71 Vector<std::unique_ptr<ExecutionContextTask>> m_pendingTasks; 73 Vector<std::unique_ptr<ExecutionContextTask>> m_pendingTasks;
72 bool m_suspended; 74 bool m_suspended;
73 WeakPtrFactory<MainThreadTaskRunner> m_weakFactory; 75 WeakPtrFactory<MainThreadTaskRunner> m_weakFactory;
74 }; 76 };
75 77
76 inline PassOwnPtr<MainThreadTaskRunner> MainThreadTaskRunner::create(ExecutionCo ntext* context) 78 inline std::unique_ptr<MainThreadTaskRunner> MainThreadTaskRunner::create(Execut ionContext* context)
77 { 79 {
78 return adoptPtr(new MainThreadTaskRunner(context)); 80 return wrapUnique(new MainThreadTaskRunner(context));
79 } 81 }
80 82
81 } // namespace blink 83 } // namespace blink
82 84
83 #endif 85 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698