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

Side by Side Diff: third_party/WebKit/Source/core/workers/WorkerThread.cpp

Issue 2402983002: [TimeZoneMonitor] Decouple renderer side impl from content to blink. (Closed)
Patch Set: Inside modules use V8PerIsolateData::mainThreadIsolate() instead of blink::mainThreadIsolate() Created 4 years, 2 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 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // Thread owns the microtask runner; reference remains 146 // Thread owns the microtask runner; reference remains
147 // valid for the lifetime of this object. 147 // valid for the lifetime of this object.
148 WorkerThread* m_workerThread; 148 WorkerThread* m_workerThread;
149 }; 149 };
150 150
151 static Mutex& threadSetMutex() { 151 static Mutex& threadSetMutex() {
152 DEFINE_THREAD_SAFE_STATIC_LOCAL(Mutex, mutex, new Mutex); 152 DEFINE_THREAD_SAFE_STATIC_LOCAL(Mutex, mutex, new Mutex);
153 return mutex; 153 return mutex;
154 } 154 }
155 155
156 static HashSet<WorkerThread*>& workerThreads() {
157 DEFINE_STATIC_LOCAL(HashSet<WorkerThread*>, threads, ());
158 return threads;
159 }
160
161 WorkerThreadLifecycleContext::WorkerThreadLifecycleContext() { 156 WorkerThreadLifecycleContext::WorkerThreadLifecycleContext() {
162 DCHECK(isMainThread()); 157 DCHECK(isMainThread());
163 } 158 }
164 159
165 WorkerThreadLifecycleContext::~WorkerThreadLifecycleContext() { 160 WorkerThreadLifecycleContext::~WorkerThreadLifecycleContext() {
166 DCHECK(isMainThread()); 161 DCHECK(isMainThread());
167 } 162 }
168 163
169 void WorkerThreadLifecycleContext::notifyContextDestroyed() { 164 void WorkerThreadLifecycleContext::notifyContextDestroyed() {
170 DCHECK(isMainThread()); 165 DCHECK(isMainThread());
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 WorkerInspectorController* WorkerThread::workerInspectorController() { 308 WorkerInspectorController* WorkerThread::workerInspectorController() {
314 DCHECK(isCurrentThread()); 309 DCHECK(isCurrentThread());
315 return m_workerInspectorController.get(); 310 return m_workerInspectorController.get();
316 } 311 }
317 312
318 unsigned WorkerThread::workerThreadCount() { 313 unsigned WorkerThread::workerThreadCount() {
319 MutexLocker lock(threadSetMutex()); 314 MutexLocker lock(threadSetMutex());
320 return workerThreads().size(); 315 return workerThreads().size();
321 } 316 }
322 317
318 HashSet<WorkerThread*>& WorkerThread::workerThreads() {
nhiroki 2016/10/17 12:01:08 DCHECK(isMainThread());
leonhsl(Using Gerrit) 2016/10/18 10:03:52 Done.
319 DEFINE_STATIC_LOCAL(HashSet<WorkerThread*>, threads, ());
320 return threads;
321 }
322
323 PlatformThreadId WorkerThread::platformThreadId() { 323 PlatformThreadId WorkerThread::platformThreadId() {
324 if (!m_requestedToStart) 324 if (!m_requestedToStart)
325 return 0; 325 return 0;
326 return workerBackingThread().backingThread().platformThread().threadId(); 326 return workerBackingThread().backingThread().platformThread().threadId();
327 } 327 }
328 328
329 bool WorkerThread::isForciblyTerminated() { 329 bool WorkerThread::isForciblyTerminated() {
330 MutexLocker lock(m_threadStateMutex); 330 MutexLocker lock(m_threadStateMutex);
331 switch (m_exitCode) { 331 switch (m_exitCode) {
332 case ExitCode::NotTerminated: 332 case ExitCode::NotTerminated:
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 MutexLocker lock(m_threadStateMutex); 685 MutexLocker lock(m_threadStateMutex);
686 return m_requestedToTerminate; 686 return m_requestedToTerminate;
687 } 687 }
688 688
689 ExitCode WorkerThread::getExitCodeForTesting() { 689 ExitCode WorkerThread::getExitCodeForTesting() {
690 MutexLocker lock(m_threadStateMutex); 690 MutexLocker lock(m_threadStateMutex);
691 return m_exitCode; 691 return m_exitCode;
692 } 692 }
693 693
694 } // namespace blink 694 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698