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

Side by Side Diff: third_party/WebKit/Source/core/streams/ReadableStreamController.h

Issue 2200303003: Remove v8CallOrCrash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: temp Created 4 years, 4 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ReadableStreamController_h 5 #ifndef ReadableStreamController_h
6 #define ReadableStreamController_h 6 #define ReadableStreamController_h
7 7
8 #include "bindings/core/v8/ScopedPersistent.h" 8 #include "bindings/core/v8/ScopedPersistent.h"
9 #include "bindings/core/v8/ScriptValue.h" 9 #include "bindings/core/v8/ScriptValue.h"
10 #include "bindings/core/v8/ToV8.h" 10 #include "bindings/core/v8/ToV8.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 v8::Local<v8::Value> controller = m_jsController.newLocal(isolate); 56 v8::Local<v8::Value> controller = m_jsController.newLocal(isolate);
57 if (controller.IsEmpty()) 57 if (controller.IsEmpty())
58 return; 58 return;
59 59
60 v8::Local<v8::Value> args[] = { controller }; 60 v8::Local<v8::Value> args[] = { controller };
61 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callExtra(scriptState , "ReadableStreamDefaultControllerClose", args); 61 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callExtra(scriptState , "ReadableStreamDefaultControllerClose", args);
62 m_jsController.clear(); 62 m_jsController.clear();
63 if (isTerminating(m_scriptState.get())) 63 if (isTerminating(m_scriptState.get()))
64 return; 64 return;
65 v8CallOrCrash(result); 65 result.ToLocalChecked();
66 } 66 }
67 67
68 double desiredSize() const 68 double desiredSize() const
69 { 69 {
70 if (isTerminating(m_scriptState.get())) 70 if (isTerminating(m_scriptState.get()))
71 return 0; 71 return 0;
72 ScriptState* scriptState = m_scriptState.get(); 72 ScriptState* scriptState = m_scriptState.get();
73 ScriptState::Scope scope(scriptState); // will assert context is valid; do not call this method when the context is invalidated 73 ScriptState::Scope scope(scriptState); // will assert context is valid; do not call this method when the context is invalidated
74 v8::Isolate* isolate = scriptState->isolate(); 74 v8::Isolate* isolate = scriptState->isolate();
75 75
76 v8::Local<v8::Value> controller = m_jsController.newLocal(isolate); 76 v8::Local<v8::Value> controller = m_jsController.newLocal(isolate);
77 if (controller.IsEmpty()) 77 if (controller.IsEmpty())
78 return 0; 78 return 0;
79 79
80 v8::Local<v8::Value> args[] = { controller }; 80 v8::Local<v8::Value> args[] = { controller };
81 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callExtra(scriptState , "ReadableStreamDefaultControllerGetDesiredSize", args); 81 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callExtra(scriptState , "ReadableStreamDefaultControllerGetDesiredSize", args);
82 if (isTerminating(m_scriptState.get())) 82 if (isTerminating(m_scriptState.get()))
83 return 0; 83 return 0;
84 84
85 return v8CallOrCrash(result).As<v8::Number>()->Value(); 85 return result.ToLocalChecked().As<v8::Number>()->Value();
86 } 86 }
87 87
88 template <typename ChunkType> 88 template <typename ChunkType>
89 void enqueue(ChunkType chunk) const 89 void enqueue(ChunkType chunk) const
90 { 90 {
91 if (isTerminating(m_scriptState.get())) 91 if (isTerminating(m_scriptState.get()))
92 return; 92 return;
93 ScriptState* scriptState = m_scriptState.get(); 93 ScriptState* scriptState = m_scriptState.get();
94 ScriptState::Scope scope(scriptState); // will assert context is valid; do not call this method when the context is invalidated 94 ScriptState::Scope scope(scriptState); // will assert context is valid; do not call this method when the context is invalidated
95 v8::Isolate* isolate = scriptState->isolate(); 95 v8::Isolate* isolate = scriptState->isolate();
96 96
97 v8::Local<v8::Value> controller = m_jsController.newLocal(isolate); 97 v8::Local<v8::Value> controller = m_jsController.newLocal(isolate);
98 if (controller.IsEmpty()) 98 if (controller.IsEmpty())
99 return; 99 return;
100 100
101 v8::Local<v8::Value> jsChunk = toV8(chunk, scriptState); 101 v8::Local<v8::Value> jsChunk = toV8(chunk, scriptState);
102 v8::Local<v8::Value> args[] = { controller, jsChunk }; 102 v8::Local<v8::Value> args[] = { controller, jsChunk };
103 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callExtra(scriptState , "ReadableStreamDefaultControllerEnqueue", args); 103 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callExtra(scriptState , "ReadableStreamDefaultControllerEnqueue", args);
104 if (isTerminating(m_scriptState.get())) 104 if (isTerminating(m_scriptState.get()))
105 return; 105 return;
106 v8CallOrCrash(result); 106 result.ToLocalChecked();
107 } 107 }
108 108
109 template <typename ErrorType> 109 template <typename ErrorType>
110 void error(ErrorType error) 110 void error(ErrorType error)
111 { 111 {
112 if (isTerminating(m_scriptState.get())) { 112 if (isTerminating(m_scriptState.get())) {
113 m_jsController.clear(); 113 m_jsController.clear();
114 return; 114 return;
115 } 115 }
116 ScriptState* scriptState = m_scriptState.get(); 116 ScriptState* scriptState = m_scriptState.get();
117 ScriptState::Scope scope(scriptState); // will assert context is valid; do not call this method when the context is invalidated 117 ScriptState::Scope scope(scriptState); // will assert context is valid; do not call this method when the context is invalidated
118 v8::Isolate* isolate = scriptState->isolate(); 118 v8::Isolate* isolate = scriptState->isolate();
119 119
120 v8::Local<v8::Value> controller = m_jsController.newLocal(isolate); 120 v8::Local<v8::Value> controller = m_jsController.newLocal(isolate);
121 if (controller.IsEmpty()) 121 if (controller.IsEmpty())
122 return; 122 return;
123 123
124 v8::Local<v8::Value> jsError = toV8(error, scriptState); 124 v8::Local<v8::Value> jsError = toV8(error, scriptState);
125 v8::Local<v8::Value> args[] = { controller, jsError }; 125 v8::Local<v8::Value> args[] = { controller, jsError };
126 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callExtra(scriptState , "ReadableStreamDefaultControllerError", args); 126 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callExtra(scriptState , "ReadableStreamDefaultControllerError", args);
127 m_jsController.clear(); 127 m_jsController.clear();
128 if (isTerminating(m_scriptState.get())) 128 if (isTerminating(m_scriptState.get()))
129 return; 129 return;
130 v8CallOrCrash(result); 130 result.ToLocalChecked();
131 } 131 }
132 132
133 private: 133 private:
134 static bool isTerminating(ScriptState* scriptState) 134 static bool isTerminating(ScriptState* scriptState)
135 { 135 {
136 ExecutionContext* executionContext = scriptState->getExecutionContext(); 136 ExecutionContext* executionContext = scriptState->getExecutionContext();
137 if (!executionContext) 137 if (!executionContext)
138 return true; 138 return true;
139 if (!executionContext->isWorkerGlobalScope()) 139 if (!executionContext->isWorkerGlobalScope())
140 return false; 140 return false;
141 return toWorkerGlobalScope(executionContext)->scriptController()->isExec utionTerminating(); 141 return toWorkerGlobalScope(executionContext)->scriptController()->isExec utionTerminating();
142 } 142 }
143 143
144 RefPtr<ScriptState> m_scriptState; 144 RefPtr<ScriptState> m_scriptState;
145 ScopedPersistent<v8::Value> m_jsController; 145 ScopedPersistent<v8::Value> m_jsController;
146 }; 146 };
147 147
148 } // namespace blink 148 } // namespace blink
149 149
150 #endif // ReadableStreamController_h 150 #endif // ReadableStreamController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698