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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptCallStack.cpp

Issue 2004313003: DevTools: migrate from OwnPtr to std::unique_ptr for inspector protocol classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselined 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) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, 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 27 matching lines...) Expand all
38 #include "platform/v8_inspector/public/V8Debugger.h" 38 #include "platform/v8_inspector/public/V8Debugger.h"
39 #include "platform/v8_inspector/public/V8StackTrace.h" 39 #include "platform/v8_inspector/public/V8StackTrace.h"
40 40
41 namespace blink { 41 namespace blink {
42 42
43 PassRefPtr<ScriptCallStack> ScriptCallStack::create(v8::Isolate* isolate, v8::Lo cal<v8::StackTrace> stackTrace, size_t maxStackSize) 43 PassRefPtr<ScriptCallStack> ScriptCallStack::create(v8::Isolate* isolate, v8::Lo cal<v8::StackTrace> stackTrace, size_t maxStackSize)
44 { 44 {
45 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 45 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
46 if (!data->threadDebugger()) 46 if (!data->threadDebugger())
47 return nullptr; 47 return nullptr;
48 OwnPtr<V8StackTrace> stack = data->threadDebugger()->debugger()->createStack Trace(stackTrace, maxStackSize); 48 std::unique_ptr<V8StackTrace> stack = data->threadDebugger()->debugger()->cr eateStackTrace(stackTrace, maxStackSize);
49 return stack ? adoptRef(new ScriptCallStack(std::move(stack))) : nullptr; 49 return stack ? adoptRef(new ScriptCallStack(std::move(stack))) : nullptr;
50 } 50 }
51 51
52 PassRefPtr<ScriptCallStack> ScriptCallStack::capture(size_t maxStackSize) 52 PassRefPtr<ScriptCallStack> ScriptCallStack::capture(size_t maxStackSize)
53 { 53 {
54 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 54 v8::Isolate* isolate = v8::Isolate::GetCurrent();
55 if (!isolate->InContext()) 55 if (!isolate->InContext())
56 return nullptr; 56 return nullptr;
57 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 57 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
58 if (!data->threadDebugger()) 58 if (!data->threadDebugger())
59 return nullptr; 59 return nullptr;
60 ScriptForbiddenScope::AllowUserAgentScript allowScripting; 60 ScriptForbiddenScope::AllowUserAgentScript allowScripting;
61 OwnPtr<V8StackTrace> stack = data->threadDebugger()->debugger()->captureStac kTrace(maxStackSize); 61 std::unique_ptr<V8StackTrace> stack = data->threadDebugger()->debugger()->ca ptureStackTrace(maxStackSize);
62 return stack ? adoptRef(new ScriptCallStack(std::move(stack))) : nullptr; 62 return stack ? adoptRef(new ScriptCallStack(std::move(stack))) : nullptr;
63 } 63 }
64 64
65 PassRefPtr<ScriptCallStack> ScriptCallStack::captureForConsole() 65 PassRefPtr<ScriptCallStack> ScriptCallStack::captureForConsole()
66 { 66 {
67 size_t stackSize = 1; 67 size_t stackSize = 1;
68 if (InspectorInstrumentation::hasFrontends()) { 68 if (InspectorInstrumentation::hasFrontends()) {
69 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 69 v8::Isolate* isolate = v8::Isolate::GetCurrent();
70 if (!isolate->InContext()) 70 if (!isolate->InContext())
71 return nullptr; 71 return nullptr;
72 if (InspectorInstrumentation::consoleAgentEnabled(currentExecutionContex t(isolate))) 72 if (InspectorInstrumentation::consoleAgentEnabled(currentExecutionContex t(isolate)))
73 stackSize = V8StackTrace::maxCallStackSizeToCapture; 73 stackSize = V8StackTrace::maxCallStackSizeToCapture;
74 } 74 }
75 return ScriptCallStack::capture(stackSize); 75 return ScriptCallStack::capture(stackSize);
76 } 76 }
77 77
78 ScriptCallStack::ScriptCallStack(PassOwnPtr<V8StackTrace> stackTrace) 78 ScriptCallStack::ScriptCallStack(std::unique_ptr<V8StackTrace> stackTrace)
79 : m_stackTrace(std::move(stackTrace)) 79 : m_stackTrace(std::move(stackTrace))
80 { 80 {
81 } 81 }
82 82
83 ScriptCallStack::~ScriptCallStack() 83 ScriptCallStack::~ScriptCallStack()
84 { 84 {
85 } 85 }
86 86
87 bool ScriptCallStack::isEmpty() const 87 bool ScriptCallStack::isEmpty() const
88 { 88 {
89 return m_stackTrace->isEmpty(); 89 return m_stackTrace->isEmpty();
90 } 90 }
91 91
92 String ScriptCallStack::topSourceURL() const 92 String ScriptCallStack::topSourceURL() const
93 { 93 {
94 return m_stackTrace->topSourceURL(); 94 return m_stackTrace->topSourceURL();
95 } 95 }
96 96
97 unsigned ScriptCallStack::topLineNumber() const 97 unsigned ScriptCallStack::topLineNumber() const
98 { 98 {
99 return m_stackTrace->topLineNumber(); 99 return m_stackTrace->topLineNumber();
100 } 100 }
101 101
102 unsigned ScriptCallStack::topColumnNumber() const 102 unsigned ScriptCallStack::topColumnNumber() const
103 { 103 {
104 return m_stackTrace->topColumnNumber(); 104 return m_stackTrace->topColumnNumber();
105 } 105 }
106 106
107 PassOwnPtr<protocol::Runtime::StackTrace> ScriptCallStack::buildInspectorObject( ) const 107 std::unique_ptr<protocol::Runtime::StackTrace> ScriptCallStack::buildInspectorOb ject() const
108 { 108 {
109 return m_stackTrace->buildInspectorObject(); 109 return m_stackTrace->buildInspectorObject();
110 } 110 }
111 111
112 void ScriptCallStack::toTracedValue(TracedValue* value, const char* name) const 112 void ScriptCallStack::toTracedValue(TracedValue* value, const char* name) const
113 { 113 {
114 if (m_stackTrace->isEmpty()) 114 if (m_stackTrace->isEmpty())
115 return; 115 return;
116 value->beginArray(name); 116 value->beginArray(name);
117 value->beginDictionary(); 117 value->beginDictionary();
118 value->setString("functionName", m_stackTrace->topFunctionName()); 118 value->setString("functionName", m_stackTrace->topFunctionName());
119 value->setString("scriptId", m_stackTrace->topScriptId()); 119 value->setString("scriptId", m_stackTrace->topScriptId());
120 value->setString("url", m_stackTrace->topSourceURL()); 120 value->setString("url", m_stackTrace->topSourceURL());
121 value->setInteger("lineNumber", m_stackTrace->topLineNumber()); 121 value->setInteger("lineNumber", m_stackTrace->topLineNumber());
122 value->setInteger("columnNumber", m_stackTrace->topColumnNumber()); 122 value->setInteger("columnNumber", m_stackTrace->topColumnNumber());
123 value->endDictionary(); 123 value->endDictionary();
124 value->endArray(); 124 value->endArray();
125 } 125 }
126 126
127 String ScriptCallStack::toString() const 127 String ScriptCallStack::toString() const
128 { 128 {
129 return m_stackTrace->toString(); 129 return m_stackTrace->toString();
130 } 130 }
131 131
132 PassOwnPtr<V8StackTrace> ScriptCallStack::copyStackTrace() const 132 std::unique_ptr<V8StackTrace> ScriptCallStack::copyStackTrace() const
133 { 133 {
134 return m_stackTrace ? m_stackTrace->clone() : nullptr; 134 return m_stackTrace ? m_stackTrace->clone() : nullptr;
135 } 135 }
136 136
137
138 } // namespace blink 137 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698