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

Side by Side Diff: Source/core/workers/WorkerRunLoop.h

Issue 17648006: Rename WorkerContext to WorkerGlobalScope (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/workers/WorkerReportingProxy.h ('k') | Source/core/workers/WorkerRunLoop.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 21 matching lines...) Expand all
32 #define WorkerRunLoop_h 32 #define WorkerRunLoop_h
33 33
34 #include "core/dom/ScriptExecutionContext.h" 34 #include "core/dom/ScriptExecutionContext.h"
35 #include <wtf/MessageQueue.h> 35 #include <wtf/MessageQueue.h>
36 #include <wtf/OwnPtr.h> 36 #include <wtf/OwnPtr.h>
37 #include <wtf/PassOwnPtr.h> 37 #include <wtf/PassOwnPtr.h>
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
41 class ModePredicate; 41 class ModePredicate;
42 class WorkerContext; 42 class WorkerGlobalScope;
43 class WorkerSharedTimer; 43 class WorkerSharedTimer;
44 44
45 class WorkerRunLoop { 45 class WorkerRunLoop {
46 public: 46 public:
47 WorkerRunLoop(); 47 WorkerRunLoop();
48 ~WorkerRunLoop(); 48 ~WorkerRunLoop();
49 49
50 // Blocking call. Waits for tasks and timers, invokes the callbacks. 50 // Blocking call. Waits for tasks and timers, invokes the callbacks.
51 void run(WorkerContext*); 51 void run(WorkerGlobalScope*);
52 52
53 enum WaitMode { WaitForMessage, DontWaitForMessage }; 53 enum WaitMode { WaitForMessage, DontWaitForMessage };
54 54
55 // Waits for a single task and returns. 55 // Waits for a single task and returns.
56 MessageQueueWaitResult runInMode(WorkerContext*, const String& mode, Wai tMode = WaitForMessage); 56 MessageQueueWaitResult runInMode(WorkerGlobalScope*, const String& mode, WaitMode = WaitForMessage);
57 57
58 void terminate(); 58 void terminate();
59 bool terminated() const { return m_messageQueue.killed(); } 59 bool terminated() const { return m_messageQueue.killed(); }
60 60
61 void postTask(PassOwnPtr<ScriptExecutionContext::Task>); 61 void postTask(PassOwnPtr<ScriptExecutionContext::Task>);
62 void postTaskAndTerminate(PassOwnPtr<ScriptExecutionContext::Task>); 62 void postTaskAndTerminate(PassOwnPtr<ScriptExecutionContext::Task>);
63 void postTaskForMode(PassOwnPtr<ScriptExecutionContext::Task>, const Str ing& mode); 63 void postTaskForMode(PassOwnPtr<ScriptExecutionContext::Task>, const Str ing& mode);
64 64
65 unsigned long createUniqueId() { return ++m_uniqueId; } 65 unsigned long createUniqueId() { return ++m_uniqueId; }
66 66
67 static String defaultMode(); 67 static String defaultMode();
68 68
69 class Task { 69 class Task {
70 WTF_MAKE_NONCOPYABLE(Task); WTF_MAKE_FAST_ALLOCATED; 70 WTF_MAKE_NONCOPYABLE(Task); WTF_MAKE_FAST_ALLOCATED;
71 public: 71 public:
72 static PassOwnPtr<Task> create(PassOwnPtr<ScriptExecutionContext::Ta sk> task, const String& mode); 72 static PassOwnPtr<Task> create(PassOwnPtr<ScriptExecutionContext::Ta sk> task, const String& mode);
73 ~Task() { } 73 ~Task() { }
74 const String& mode() const { return m_mode; } 74 const String& mode() const { return m_mode; }
75 void performTask(const WorkerRunLoop&, ScriptExecutionContext*); 75 void performTask(const WorkerRunLoop&, ScriptExecutionContext*);
76 76
77 private: 77 private:
78 Task(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mo de); 78 Task(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mo de);
79 79
80 OwnPtr<ScriptExecutionContext::Task> m_task; 80 OwnPtr<ScriptExecutionContext::Task> m_task;
81 String m_mode; 81 String m_mode;
82 }; 82 };
83 83
84 private: 84 private:
85 friend class RunLoopSetup; 85 friend class RunLoopSetup;
86 MessageQueueWaitResult runInMode(WorkerContext*, const ModePredicate&, W aitMode); 86 MessageQueueWaitResult runInMode(WorkerGlobalScope*, const ModePredicate &, WaitMode);
87 87
88 // Runs any clean up tasks that are currently in the queue and returns. 88 // Runs any clean up tasks that are currently in the queue and returns.
89 // This should only be called when the context is closed or loop has bee n terminated. 89 // This should only be called when the context is closed or loop has bee n terminated.
90 void runCleanupTasks(WorkerContext*); 90 void runCleanupTasks(WorkerGlobalScope*);
91 91
92 void idleNotification(double idlenessInterval); 92 void idleNotification(double idlenessInterval);
93 93
94 MessageQueue<Task> m_messageQueue; 94 MessageQueue<Task> m_messageQueue;
95 OwnPtr<WorkerSharedTimer> m_sharedTimer; 95 OwnPtr<WorkerSharedTimer> m_sharedTimer;
96 int m_nestedCount; 96 int m_nestedCount;
97 unsigned long m_uniqueId; 97 unsigned long m_uniqueId;
98 double m_currentIdleIntervalInSeconds; 98 double m_currentIdleIntervalInSeconds;
99 double m_nextIdleNotificationTime; 99 double m_nextIdleNotificationTime;
100 }; 100 };
101 101
102 } // namespace WebCore 102 } // namespace WebCore
103 103
104 #endif // WorkerRunLoop_h 104 #endif // WorkerRunLoop_h
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerReportingProxy.h ('k') | Source/core/workers/WorkerRunLoop.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698