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

Side by Side Diff: third_party/WebKit/Source/core/workers/WorkerOrWorkletGlobalScope.h

Issue 2857583003: Worker: Avoid sending IPC messages for features already counted (Closed)
Patch Set: wip Created 3 years, 7 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 WorkerOrWorkletGlobalScope_h 5 #ifndef WorkerOrWorkletGlobalScope_h
6 #define WorkerOrWorkletGlobalScope_h 6 #define WorkerOrWorkletGlobalScope_h
7 7
8 #include "core/dom/ExecutionContext.h" 8 #include "core/dom/ExecutionContext.h"
9 #include "core/frame/UseCounter.h" 9 #include "core/frame/UseCounter.h"
10 10
(...skipping 23 matching lines...) Expand all
34 // WorkerGlobalScope#close() method). If this returns true, the worker is 34 // WorkerGlobalScope#close() method). If this returns true, the worker is
35 // going to be shutdown after the current task execution. Globals that 35 // going to be shutdown after the current task execution. Globals that
36 // don't support close operation should always return false. 36 // don't support close operation should always return false.
37 virtual bool IsClosing() const = 0; 37 virtual bool IsClosing() const = 0;
38 38
39 // Should be called before destroying the global scope object. Allows 39 // Should be called before destroying the global scope object. Allows
40 // sub-classes to perform any cleanup needed. 40 // sub-classes to perform any cleanup needed.
41 virtual void Dispose() = 0; 41 virtual void Dispose() = 0;
42 42
43 // Called from UseCounter to record API use in this execution context. 43 // Called from UseCounter to record API use in this execution context.
44 virtual void CountFeature(UseCounter::Feature) = 0; 44 void CountFeature(UseCounter::Feature);
45 45
46 // Called from UseCounter to record deprecated API use in this execution 46 // Called from UseCounter to record deprecated API use in this execution
47 // context. Sub-classes should call addDeprecationMessage() in this function. 47 // context.
48 virtual void CountDeprecation(UseCounter::Feature) = 0; 48 void CountDeprecation(UseCounter::Feature);
49 49
50 // May return nullptr if this global scope is not threaded (i.e., 50 // May return nullptr if this global scope is not threaded (i.e.,
51 // MainThreadWorkletGlobalScope) or after dispose() is called. 51 // MainThreadWorkletGlobalScope) or after dispose() is called.
52 virtual WorkerThread* GetThread() const = 0; 52 virtual WorkerThread* GetThread() const = 0;
53 53
54 protected: 54 protected:
55 // Adds a deprecation message to the console. 55 virtual void ReportFeature(UseCounter::Feature) = 0;
56 void AddDeprecationMessage(UseCounter::Feature); 56 virtual void ReportDeprecation(UseCounter::Feature) = 0;
57 57
58 private: 58 private:
59 void RunTask(std::unique_ptr<ExecutionContextTask>, bool is_instrumented); 59 void RunTask(std::unique_ptr<ExecutionContextTask>, bool is_instrumented);
60 60
61 BitVector deprecation_warning_bits_; 61 // This is the set of features that this worker has used.
62 BitVector used_features_;
62 }; 63 };
63 64
64 DEFINE_TYPE_CASTS( 65 DEFINE_TYPE_CASTS(
65 WorkerOrWorkletGlobalScope, 66 WorkerOrWorkletGlobalScope,
66 ExecutionContext, 67 ExecutionContext,
67 context, 68 context,
68 (context->IsWorkerGlobalScope() || context->IsWorkletGlobalScope()), 69 (context->IsWorkerGlobalScope() || context->IsWorkletGlobalScope()),
69 (context.IsWorkerGlobalScope() || context.IsWorkletGlobalScope())); 70 (context.IsWorkerGlobalScope() || context.IsWorkletGlobalScope()));
70 71
71 } // namespace blink 72 } // namespace blink
72 73
73 #endif // WorkerOrWorkletGlobalScope_h 74 #endif // WorkerOrWorkletGlobalScope_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698