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

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

Issue 2817533003: Replace ASSERT, RELEASE_ASSERT, and ASSERT_NOT_REACHED in bindings (Closed)
Patch Set: fixed dcheck build error Created 3 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 27 matching lines...) Expand all
38 #include "platform/wtf/LeakAnnotations.h" 38 #include "platform/wtf/LeakAnnotations.h"
39 #include "platform/wtf/PtrUtil.h" 39 #include "platform/wtf/PtrUtil.h"
40 #include "public/platform/Platform.h" 40 #include "public/platform/Platform.h"
41 #include "v8/include/v8-debug.h" 41 #include "v8/include/v8-debug.h"
42 42
43 namespace blink { 43 namespace blink {
44 44
45 static V8PerIsolateData* g_main_thread_per_isolate_data = 0; 45 static V8PerIsolateData* g_main_thread_per_isolate_data = 0;
46 46
47 static void BeforeCallEnteredCallback(v8::Isolate* isolate) { 47 static void BeforeCallEnteredCallback(v8::Isolate* isolate) {
48 RELEASE_ASSERT(!ScriptForbiddenScope::IsScriptForbidden()); 48 CHECK(!ScriptForbiddenScope::IsScriptForbidden());
49 } 49 }
50 50
51 static void MicrotasksCompletedCallback(v8::Isolate* isolate) { 51 static void MicrotasksCompletedCallback(v8::Isolate* isolate) {
52 V8PerIsolateData::From(isolate)->RunEndOfScopeTasks(); 52 V8PerIsolateData::From(isolate)->RunEndOfScopeTasks();
53 } 53 }
54 54
55 V8PerIsolateData::V8PerIsolateData(WebTaskRunner* task_runner) 55 V8PerIsolateData::V8PerIsolateData(WebTaskRunner* task_runner)
56 : isolate_holder_( 56 : isolate_holder_(
57 task_runner ? task_runner->ToSingleThreadTaskRunner() : nullptr, 57 task_runner ? task_runner->ToSingleThreadTaskRunner() : nullptr,
58 gin::IsolateHolder::kSingleThread, 58 gin::IsolateHolder::kSingleThread,
59 IsMainThread() ? gin::IsolateHolder::kDisallowAtomicsWait 59 IsMainThread() ? gin::IsolateHolder::kDisallowAtomicsWait
60 : gin::IsolateHolder::kAllowAtomicsWait), 60 : gin::IsolateHolder::kAllowAtomicsWait),
61 string_cache_(WTF::WrapUnique(new StringCache(GetIsolate()))), 61 string_cache_(WTF::WrapUnique(new StringCache(GetIsolate()))),
62 private_property_(V8PrivateProperty::Create()), 62 private_property_(V8PrivateProperty::Create()),
63 constructor_mode_(ConstructorMode::kCreateNewObject), 63 constructor_mode_(ConstructorMode::kCreateNewObject),
64 use_counter_disabled_(false), 64 use_counter_disabled_(false),
65 is_handling_recursion_level_error_(false), 65 is_handling_recursion_level_error_(false),
66 is_reporting_exception_(false) { 66 is_reporting_exception_(false) {
67 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. 67 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone.
68 GetIsolate()->Enter(); 68 GetIsolate()->Enter();
69 GetIsolate()->AddBeforeCallEnteredCallback(&BeforeCallEnteredCallback); 69 GetIsolate()->AddBeforeCallEnteredCallback(&BeforeCallEnteredCallback);
70 GetIsolate()->AddMicrotasksCompletedCallback(&MicrotasksCompletedCallback); 70 GetIsolate()->AddMicrotasksCompletedCallback(&MicrotasksCompletedCallback);
71 if (IsMainThread()) 71 if (IsMainThread())
72 g_main_thread_per_isolate_data = this; 72 g_main_thread_per_isolate_data = this;
73 } 73 }
74 74
75 V8PerIsolateData::~V8PerIsolateData() {} 75 V8PerIsolateData::~V8PerIsolateData() {}
76 76
77 v8::Isolate* V8PerIsolateData::MainThreadIsolate() { 77 v8::Isolate* V8PerIsolateData::MainThreadIsolate() {
78 ASSERT(g_main_thread_per_isolate_data); 78 DCHECK(g_main_thread_per_isolate_data);
79 return g_main_thread_per_isolate_data->GetIsolate(); 79 return g_main_thread_per_isolate_data->GetIsolate();
80 } 80 }
81 81
82 v8::Isolate* V8PerIsolateData::Initialize(WebTaskRunner* task_runner) { 82 v8::Isolate* V8PerIsolateData::Initialize(WebTaskRunner* task_runner) {
83 V8PerIsolateData* data = new V8PerIsolateData(task_runner); 83 V8PerIsolateData* data = new V8PerIsolateData(task_runner);
84 v8::Isolate* isolate = data->GetIsolate(); 84 v8::Isolate* isolate = data->GetIsolate();
85 isolate->SetData(gin::kEmbedderBlink, data); 85 isolate->SetData(gin::kEmbedderBlink, data);
86 return isolate; 86 return isolate;
87 } 87 }
88 88
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 void V8PerIsolateData::AddEndOfScopeTask(std::unique_ptr<EndOfScopeTask> task) { 273 void V8PerIsolateData::AddEndOfScopeTask(std::unique_ptr<EndOfScopeTask> task) {
274 end_of_scope_tasks_.push_back(std::move(task)); 274 end_of_scope_tasks_.push_back(std::move(task));
275 } 275 }
276 276
277 void V8PerIsolateData::RunEndOfScopeTasks() { 277 void V8PerIsolateData::RunEndOfScopeTasks() {
278 Vector<std::unique_ptr<EndOfScopeTask>> tasks; 278 Vector<std::unique_ptr<EndOfScopeTask>> tasks;
279 tasks.Swap(end_of_scope_tasks_); 279 tasks.Swap(end_of_scope_tasks_);
280 for (const auto& task : tasks) 280 for (const auto& task : tasks)
281 task->Run(); 281 task->Run();
282 ASSERT(end_of_scope_tasks_.IsEmpty()); 282 DCHECK(end_of_scope_tasks_.IsEmpty());
283 } 283 }
284 284
285 void V8PerIsolateData::ClearEndOfScopeTasks() { 285 void V8PerIsolateData::ClearEndOfScopeTasks() {
286 end_of_scope_tasks_.Clear(); 286 end_of_scope_tasks_.Clear();
287 } 287 }
288 288
289 void V8PerIsolateData::SetThreadDebugger( 289 void V8PerIsolateData::SetThreadDebugger(
290 std::unique_ptr<V8PerIsolateData::Data> thread_debugger) { 290 std::unique_ptr<V8PerIsolateData::Data> thread_debugger) {
291 ASSERT(!thread_debugger_); 291 DCHECK(!thread_debugger_);
292 thread_debugger_ = std::move(thread_debugger); 292 thread_debugger_ = std::move(thread_debugger);
293 } 293 }
294 294
295 V8PerIsolateData::Data* V8PerIsolateData::ThreadDebugger() { 295 V8PerIsolateData::Data* V8PerIsolateData::ThreadDebugger() {
296 return thread_debugger_.get(); 296 return thread_debugger_.get();
297 } 297 }
298 298
299 void V8PerIsolateData::AddActiveScriptWrappable( 299 void V8PerIsolateData::AddActiveScriptWrappable(
300 ActiveScriptWrappableBase* wrappable) { 300 ActiveScriptWrappableBase* wrappable) {
301 if (!active_script_wrappables_) 301 if (!active_script_wrappables_)
302 active_script_wrappables_ = new ActiveScriptWrappableSet(); 302 active_script_wrappables_ = new ActiveScriptWrappableSet();
303 303
304 active_script_wrappables_->insert(wrappable); 304 active_script_wrappables_->insert(wrappable);
305 } 305 }
306 306
307 void V8PerIsolateData::TemporaryScriptWrappableVisitorScope:: 307 void V8PerIsolateData::TemporaryScriptWrappableVisitorScope::
308 SwapWithV8PerIsolateDataVisitor( 308 SwapWithV8PerIsolateDataVisitor(
309 std::unique_ptr<ScriptWrappableVisitor>& visitor) { 309 std::unique_ptr<ScriptWrappableVisitor>& visitor) {
310 ScriptWrappableVisitor* current = CurrentVisitor(); 310 ScriptWrappableVisitor* current = CurrentVisitor();
311 if (current) 311 if (current)
312 current->PerformCleanup(); 312 current->PerformCleanup();
313 313
314 V8PerIsolateData::From(isolate_)->script_wrappable_visitor_.swap( 314 V8PerIsolateData::From(isolate_)->script_wrappable_visitor_.swap(
315 saved_visitor_); 315 saved_visitor_);
316 isolate_->SetEmbedderHeapTracer(CurrentVisitor()); 316 isolate_->SetEmbedderHeapTracer(CurrentVisitor());
317 } 317 }
318 318
319 } // namespace blink 319 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698