OLD | NEW |
---|---|
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 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 #include "platform/heap/Heap.h" | 46 #include "platform/heap/Heap.h" |
47 #include "platform/wtf/Assertions.h" | 47 #include "platform/wtf/Assertions.h" |
48 #include "platform/wtf/PtrUtil.h" | 48 #include "platform/wtf/PtrUtil.h" |
49 #include "platform/wtf/WTF.h" | 49 #include "platform/wtf/WTF.h" |
50 #include "platform/wtf/allocator/Partitions.h" | 50 #include "platform/wtf/allocator/Partitions.h" |
51 #include "platform/wtf/text/AtomicString.h" | 51 #include "platform/wtf/text/AtomicString.h" |
52 #include "platform/wtf/text/TextEncoding.h" | 52 #include "platform/wtf/text/TextEncoding.h" |
53 #include "public/platform/Platform.h" | 53 #include "public/platform/Platform.h" |
54 #include "public/platform/WebThread.h" | 54 #include "public/platform/WebThread.h" |
55 #include "v8/include/v8.h" | 55 #include "v8/include/v8.h" |
56 #include "web/WebInitializer.h" | |
56 | 57 |
57 namespace blink { | 58 namespace blink { |
58 | 59 |
59 namespace { | 60 namespace { |
60 | 61 |
61 class EndOfTaskRunner : public WebThread::TaskObserver { | 62 class EndOfTaskRunner : public WebThread::TaskObserver { |
62 public: | 63 public: |
63 void WillProcessTask() override { AnimationClock::NotifyTaskStart(); } | 64 void WillProcessTask() override { AnimationClock::NotifyTaskStart(); } |
64 void DidProcessTask() override { | 65 void DidProcessTask() override { |
65 Microtask::PerformCheckpoint(MainThreadIsolate()); | 66 Microtask::PerformCheckpoint(MainThreadIsolate()); |
66 V8Initializer::ReportRejectedPromisesOnMainThread(); | 67 V8Initializer::ReportRejectedPromisesOnMainThread(); |
67 } | 68 } |
68 }; | 69 }; |
69 | 70 |
70 } // namespace | 71 } // namespace |
71 | 72 |
72 static WebThread::TaskObserver* g_end_of_task_runner = nullptr; | 73 static WebThread::TaskObserver* g_end_of_task_runner = nullptr; |
73 | 74 |
74 static ModulesInitializer& GetModulesInitializer() { | 75 static ModulesInitializer& GetModulesInitializer() { |
75 DEFINE_STATIC_LOCAL(std::unique_ptr<ModulesInitializer>, initializer, | 76 DEFINE_STATIC_LOCAL(std::unique_ptr<ModulesInitializer>, initializer, |
76 (WTF::WrapUnique(new ModulesInitializer))); | 77 (WTF::WrapUnique(new ModulesInitializer))); |
77 return *initializer; | 78 return *initializer; |
78 } | 79 } |
79 | 80 |
81 static WebInitializer& GetWebInitializer() { | |
82 DEFINE_STATIC_LOCAL(std::unique_ptr<WebInitializer>, initializer, | |
dcheng
2017/05/22 09:16:49
Nit: Just say WebInitializer directly here; static
sashab
2017/05/29 04:34:00
Removed this code and inlined into Initialize meth
| |
83 (WTF::WrapUnique(new WebInitializer))); | |
84 return *initializer; | |
85 } | |
86 | |
80 void Initialize(Platform* platform) { | 87 void Initialize(Platform* platform) { |
81 Platform::Initialize(platform); | 88 Platform::Initialize(platform); |
82 | 89 |
83 V8Initializer::InitializeMainThread(); | 90 V8Initializer::InitializeMainThread(); |
84 | 91 |
85 GetModulesInitializer().Initialize(); | 92 GetModulesInitializer().Initialize(); |
93 GetWebInitializer().Initialize(); | |
86 | 94 |
87 // currentThread is null if we are running on a thread without a message loop. | 95 // currentThread is null if we are running on a thread without a message loop. |
88 if (WebThread* current_thread = platform->CurrentThread()) { | 96 if (WebThread* current_thread = platform->CurrentThread()) { |
89 DCHECK(!g_end_of_task_runner); | 97 DCHECK(!g_end_of_task_runner); |
90 g_end_of_task_runner = new EndOfTaskRunner; | 98 g_end_of_task_runner = new EndOfTaskRunner; |
91 current_thread->AddTaskObserver(g_end_of_task_runner); | 99 current_thread->AddTaskObserver(g_end_of_task_runner); |
92 } | 100 } |
93 } | 101 } |
94 | 102 |
95 v8::Isolate* MainThreadIsolate() { | 103 v8::Isolate* MainThreadIsolate() { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 void MemoryPressureNotificationToWorkerThreadIsolates( | 140 void MemoryPressureNotificationToWorkerThreadIsolates( |
133 v8::MemoryPressureLevel level) { | 141 v8::MemoryPressureLevel level) { |
134 WorkerBackingThread::MemoryPressureNotificationToWorkerThreadIsolates(level); | 142 WorkerBackingThread::MemoryPressureNotificationToWorkerThreadIsolates(level); |
135 } | 143 } |
136 | 144 |
137 void SetRAILModeOnWorkerThreadIsolates(v8::RAILMode rail_mode) { | 145 void SetRAILModeOnWorkerThreadIsolates(v8::RAILMode rail_mode) { |
138 WorkerBackingThread::SetRAILModeOnWorkerThreadIsolates(rail_mode); | 146 WorkerBackingThread::SetRAILModeOnWorkerThreadIsolates(rail_mode); |
139 } | 147 } |
140 | 148 |
141 } // namespace blink | 149 } // namespace blink |
OLD | NEW |