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

Side by Side Diff: Source/bindings/core/v8/ScriptProfiler.cpp

Issue 1236473002: Fix virtual/override/final usage in Source/bindings/. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 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 /* 1 /*
2 * Copyright (c) 2011, Google Inc. All rights reserved. 2 * Copyright (c) 2011, 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 v8::HeapProfiler* profiler = isolate->GetHeapProfiler(); 136 v8::HeapProfiler* profiler = isolate->GetHeapProfiler();
137 profiler->ClearObjectIds(); 137 profiler->ClearObjectIds();
138 } 138 }
139 139
140 namespace { 140 namespace {
141 141
142 class ActivityControlAdapter final : public v8::ActivityControl { 142 class ActivityControlAdapter final : public v8::ActivityControl {
143 public: 143 public:
144 ActivityControlAdapter(ScriptProfiler::HeapSnapshotProgress* progress) 144 ActivityControlAdapter(ScriptProfiler::HeapSnapshotProgress* progress)
145 : m_progress(progress), m_firstReport(true) { } 145 : m_progress(progress), m_firstReport(true) { }
146 virtual ControlOption ReportProgressValue(int done, int total) override 146 ControlOption ReportProgressValue(int done, int total) override
147 { 147 {
148 ControlOption result = m_progress->isCanceled() ? kAbort : kContinue; 148 ControlOption result = m_progress->isCanceled() ? kAbort : kContinue;
149 if (m_firstReport) { 149 if (m_firstReport) {
150 m_firstReport = false; 150 m_firstReport = false;
151 m_progress->Start(total); 151 m_progress->Start(total);
152 } else { 152 } else {
153 m_progress->Worked(done); 153 m_progress->Worked(done);
154 } 154 }
155 if (done >= total) 155 if (done >= total)
156 m_progress->Done(); 156 m_progress->Done();
157 return result; 157 return result;
158 } 158 }
159 private: 159 private:
160 ScriptProfiler::HeapSnapshotProgress* m_progress; 160 ScriptProfiler::HeapSnapshotProgress* m_progress;
161 bool m_firstReport; 161 bool m_firstReport;
162 }; 162 };
163 163
164 class GlobalObjectNameResolver final : public v8::HeapProfiler::ObjectNameResolv er { 164 class GlobalObjectNameResolver final : public v8::HeapProfiler::ObjectNameResolv er {
165 public: 165 public:
166 virtual const char* GetName(v8::Local<v8::Object> object) override 166 const char* GetName(v8::Local<v8::Object> object) override
167 { 167 {
168 DOMWindow* window = toDOMWindow(v8::Isolate::GetCurrent(), object); 168 DOMWindow* window = toDOMWindow(v8::Isolate::GetCurrent(), object);
169 if (!window) 169 if (!window)
170 return 0; 170 return 0;
171 CString url = toLocalDOMWindow(window)->document()->url().string().utf8( ); 171 CString url = toLocalDOMWindow(window)->document()->url().string().utf8( );
172 m_strings.append(url); 172 m_strings.append(url);
173 return url.data(); 173 return url.data();
174 } 174 }
175 175
176 private: 176 private:
177 Vector<CString> m_strings; 177 Vector<CString> m_strings;
178 }; 178 };
179 179
180 } // namespace 180 } // namespace
181 181
182 void ScriptProfiler::startTrackingHeapObjects(bool trackAllocations) 182 void ScriptProfiler::startTrackingHeapObjects(bool trackAllocations)
183 { 183 {
184 v8::Isolate::GetCurrent()->GetHeapProfiler()->StartTrackingHeapObjects(track Allocations); 184 v8::Isolate::GetCurrent()->GetHeapProfiler()->StartTrackingHeapObjects(track Allocations);
185 } 185 }
186 186
187 namespace { 187 namespace {
188 188
189 class HeapStatsStream : public v8::OutputStream { 189 class HeapStatsStream : public v8::OutputStream {
190 public: 190 public:
191 HeapStatsStream(ScriptProfiler::OutputStream* stream) : m_stream(stream) { } 191 HeapStatsStream(ScriptProfiler::OutputStream* stream) : m_stream(stream) { }
192 virtual void EndOfStream() override { } 192 void EndOfStream() override { }
193 193
194 virtual WriteResult WriteAsciiChunk(char* data, int size) override 194 WriteResult WriteAsciiChunk(char* data, int size) override
195 { 195 {
196 ASSERT(false); 196 ASSERT(false);
197 return kAbort; 197 return kAbort;
198 } 198 }
199 199
200 virtual WriteResult WriteHeapStatsChunk(v8::HeapStatsUpdate* updateData, int count) override 200 WriteResult WriteHeapStatsChunk(v8::HeapStatsUpdate* updateData, int count) override
201 { 201 {
202 Vector<uint32_t> rawData(count * 3); 202 Vector<uint32_t> rawData(count * 3);
203 for (int i = 0; i < count; ++i) { 203 for (int i = 0; i < count; ++i) {
204 int offset = i * 3; 204 int offset = i * 3;
205 rawData[offset] = updateData[i].index; 205 rawData[offset] = updateData[i].index;
206 rawData[offset + 1] = updateData[i].count; 206 rawData[offset + 1] = updateData[i].count;
207 rawData[offset + 2] = updateData[i].size; 207 rawData[offset + 2] = updateData[i].size;
208 } 208 }
209 m_stream->write(rawData.data(), rawData.size()); 209 m_stream->write(rawData.data(), rawData.size());
210 return kContinue; 210 return kContinue;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 266 }
267 267
268 void ScriptProfiler::setIdle(bool isIdle) 268 void ScriptProfiler::setIdle(bool isIdle)
269 { 269 {
270 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 270 v8::Isolate* isolate = v8::Isolate::GetCurrent();
271 if (v8::CpuProfiler* profiler = isolate->GetCpuProfiler()) 271 if (v8::CpuProfiler* profiler = isolate->GetCpuProfiler())
272 profiler->SetIdle(isIdle); 272 profiler->SetIdle(isIdle);
273 } 273 }
274 274
275 } // namespace blink 275 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptHeapSnapshot.cpp ('k') | Source/bindings/core/v8/ScriptPromiseProperty.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698