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

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

Issue 2236833002: Pass per-frame task runners to Workers (when possible) [2nd try] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, lifecycle observer + TaskType 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/workers/ParentFrameTaskRunners.h"
6
7 #include "core/dom/ContextLifecycleObserver.h"
8 #include "core/dom/Document.h"
9 #include "wtf/Assertions.h"
10
11 namespace blink {
12
13 class ParentFrameTaskRunners::Observer final : public GarbageCollected<Observer> , public ContextLifecycleObserver {
haraken 2016/08/11 14:57:43 I'd use LocalFrameLifecycleObserver instead, since
kinuko 2016/08/11 23:21:37 Wanted to make it an observer only in in-process c
14 USING_GARBAGE_COLLECTED_MIXIN(Observer);
15 public:
16 Observer(ParentFrameTaskRunners* owner, Document* document)
17 : ContextLifecycleObserver(document)
18 , m_owner(owner)
19 {
20 }
21
22 void contextDestroyed() override
23 {
24 m_owner->contextDestroyed();
25 }
26
27 DEFINE_INLINE_VIRTUAL_TRACE()
28 {
29 ContextLifecycleObserver::trace(visitor);
30 }
31
32 ParentFrameTaskRunners* m_owner;
33 };
34
35 ParentFrameTaskRunners::~ParentFrameTaskRunners()
36 {
37 }
38
39 WebTaskRunner* ParentFrameTaskRunners::get(TaskType type)
haraken 2016/08/11 14:57:43 Nit: I'd rename this to ParentFrameTaskRunnerHelpe
kinuko 2016/08/11 23:21:37 I slightly prefer the current name as this class a
40 {
41 // For now we only support most basic three task types for workers.
42 // (Probably some unthrottled tasks should be moved to Internal type)
haraken 2016/08/11 14:57:42 Yeah, our plan is to limit the unthrottled task ru
kinuko 2016/08/11 23:21:37 I agree, but wanted to avoid mixing up additional
43 switch (type) {
44 case TaskType::Networking:
45 return m_loadingTaskRunner;
46 case TaskType::Unthrottled:
47 return m_unthrottledTaskRunner;
48 case TaskType::Timer:
49 return m_timerTaskRunner;
50 default:
51 NOTREACHED();
52 }
53 return nullptr;
54 }
55
56 ParentFrameTaskRunners::ParentFrameTaskRunners(Document* document)
haraken 2016/08/11 14:57:43 Would it make more sense to change the parameter f
kinuko 2016/08/11 23:21:37 For out-of-process workers taking LocalFrame feels
57 : m_unthrottledTaskRunner(TaskRunnerHelper::getUnthrottledTaskRunner(documen t))
58 , m_timerTaskRunner(TaskRunnerHelper::getTimerTaskRunner(document))
59 , m_loadingTaskRunner(TaskRunnerHelper::getLoadingTaskRunner(document))
60 {
61 if (!document)
62 return;
63
64 m_observer = new Observer(this, document);
65 DCHECK(document->isContextThread());
66 }
67
68 void ParentFrameTaskRunners::contextDestroyed()
haraken 2016/08/11 14:57:43 Wouldn't contextDestroyed() (called by the main th
kinuko 2016/08/11 23:21:36 Done.
69 {
70 Document* document = nullptr;
71 m_unthrottledTaskRunner = TaskRunnerHelper::getUnthrottledTaskRunner(documen t);
haraken 2016/08/11 14:57:43 Note that these APIs are deprecated. Use TaskRunne
kinuko 2016/08/11 23:21:37 Yep, I cut corners before I get initial feedback.
72 m_timerTaskRunner = TaskRunnerHelper::getTimerTaskRunner(document);
73 m_loadingTaskRunner = TaskRunnerHelper::getLoadingTaskRunner(document);
74 }
75
76 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698