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

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

Issue 1857713004: DevTools: simplify the async instrumentation harness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #else 63 #else
64 AllowCrossThreadAccess(m_weakFactory.createWeakPtr()), 64 AllowCrossThreadAccess(m_weakFactory.createWeakPtr()),
65 #endif 65 #endif
66 task, 66 task,
67 isInspectorTask)); 67 isInspectorTask));
68 } 68 }
69 69
70 void MainThreadTaskRunner::postTask(const WebTraceLocation& location, PassOwnPtr <ExecutionContextTask> task) 70 void MainThreadTaskRunner::postTask(const WebTraceLocation& location, PassOwnPtr <ExecutionContextTask> task)
71 { 71 {
72 if (!task->taskNameForInstrumentation().isEmpty()) 72 if (!task->taskNameForInstrumentation().isEmpty())
73 InspectorInstrumentation::didPostExecutionContextTask(m_context, task.ge t()); 73 InspectorInstrumentation::asyncTaskScheduled(m_context, task->taskNameFo rInstrumentation(), task.get());
74 postTaskInternal(location, task, false); 74 postTaskInternal(location, task, false);
75 } 75 }
76 76
77 void MainThreadTaskRunner::postInspectorTask(const WebTraceLocation& location, P assOwnPtr<ExecutionContextTask> task) 77 void MainThreadTaskRunner::postInspectorTask(const WebTraceLocation& location, P assOwnPtr<ExecutionContextTask> task)
78 { 78 {
79 postTaskInternal(location, task, true); 79 postTaskInternal(location, task, true);
80 } 80 }
81 81
82 void MainThreadTaskRunner::perform(PassOwnPtr<ExecutionContextTask> task, bool i sInspectorTask) 82 void MainThreadTaskRunner::perform(PassOwnPtr<ExecutionContextTask> task, bool i sInspectorTask)
83 { 83 {
84 if (!isInspectorTask && (m_context->tasksNeedSuspension() || !m_pendingTasks .isEmpty())) { 84 if (!isInspectorTask && (m_context->tasksNeedSuspension() || !m_pendingTasks .isEmpty())) {
85 m_pendingTasks.append(task); 85 m_pendingTasks.append(task);
86 return; 86 return;
87 } 87 }
88 88
89 const bool instrumenting = !isInspectorTask && !task->taskNameForInstrumenta tion().isEmpty(); 89 InspectorInstrumentation::AsyncTask asyncTask(m_context, task.get(), !isInsp ectorTask);
90 if (instrumenting)
91 InspectorInstrumentation::willPerformExecutionContextTask(m_context, tas k.get());
92 task->performTask(m_context); 90 task->performTask(m_context);
93 if (instrumenting)
94 InspectorInstrumentation::didPerformExecutionContextTask(m_context);
95 } 91 }
96 92
97 void MainThreadTaskRunner::suspend() 93 void MainThreadTaskRunner::suspend()
98 { 94 {
99 ASSERT(!m_suspended); 95 ASSERT(!m_suspended);
100 m_pendingTasksTimer.stop(); 96 m_pendingTasksTimer.stop();
101 m_suspended = true; 97 m_suspended = true;
102 } 98 }
103 99
104 void MainThreadTaskRunner::resume() 100 void MainThreadTaskRunner::resume()
105 { 101 {
106 ASSERT(m_suspended); 102 ASSERT(m_suspended);
107 if (!m_pendingTasks.isEmpty()) 103 if (!m_pendingTasks.isEmpty())
108 m_pendingTasksTimer.startOneShot(0, BLINK_FROM_HERE); 104 m_pendingTasksTimer.startOneShot(0, BLINK_FROM_HERE);
109 105
110 m_suspended = false; 106 m_suspended = false;
111 } 107 }
112 108
113 void MainThreadTaskRunner::pendingTasksTimerFired(Timer<MainThreadTaskRunner>*) 109 void MainThreadTaskRunner::pendingTasksTimerFired(Timer<MainThreadTaskRunner>*)
114 { 110 {
115 while (!m_pendingTasks.isEmpty()) { 111 while (!m_pendingTasks.isEmpty()) {
116 OwnPtr<ExecutionContextTask> task = m_pendingTasks[0].release(); 112 OwnPtr<ExecutionContextTask> task = m_pendingTasks[0].release();
117 m_pendingTasks.remove(0); 113 m_pendingTasks.remove(0);
118 const bool instrumenting = !task->taskNameForInstrumentation().isEmpty() ; 114 const bool instrumenting = !task->taskNameForInstrumentation().isEmpty() ;
119 if (instrumenting) 115 InspectorInstrumentation::AsyncTask asyncTask(m_context, task.get(), ins trumenting);
120 InspectorInstrumentation::willPerformExecutionContextTask(m_context, task.get());
121 task->performTask(m_context); 116 task->performTask(m_context);
122 if (instrumenting)
123 InspectorInstrumentation::didPerformExecutionContextTask(m_context);
124 } 117 }
125 } 118 }
126 119
127 } // namespace blink 120 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698