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

Side by Side Diff: Source/core/loader/WorkerThreadableLoader.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/loader/ThreadableLoader.cpp ('k') | Source/core/loader/WorkerThreadableLoader.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 28 matching lines...) Expand all
39 #include <wtf/PassRefPtr.h> 39 #include <wtf/PassRefPtr.h>
40 #include <wtf/RefCounted.h> 40 #include <wtf/RefCounted.h>
41 #include <wtf/RefPtr.h> 41 #include <wtf/RefPtr.h>
42 #include <wtf/text/WTFString.h> 42 #include <wtf/text/WTFString.h>
43 #include <wtf/Threading.h> 43 #include <wtf/Threading.h>
44 44
45 namespace WebCore { 45 namespace WebCore {
46 46
47 class ResourceError; 47 class ResourceError;
48 class ResourceRequest; 48 class ResourceRequest;
49 class WorkerContext; 49 class WorkerGlobalScope;
50 class WorkerLoaderProxy; 50 class WorkerLoaderProxy;
51 struct CrossThreadResourceResponseData; 51 struct CrossThreadResourceResponseData;
52 struct CrossThreadResourceRequestData; 52 struct CrossThreadResourceRequestData;
53 53
54 class WorkerThreadableLoader : public RefCounted<WorkerThreadableLoader>, pu blic ThreadableLoader { 54 class WorkerThreadableLoader : public RefCounted<WorkerThreadableLoader>, pu blic ThreadableLoader {
55 WTF_MAKE_FAST_ALLOCATED; 55 WTF_MAKE_FAST_ALLOCATED;
56 public: 56 public:
57 static void loadResourceSynchronously(WorkerContext*, const ResourceRequ est&, ThreadableLoaderClient&, const ThreadableLoaderOptions&); 57 static void loadResourceSynchronously(WorkerGlobalScope*, const Resource Request&, ThreadableLoaderClient&, const ThreadableLoaderOptions&);
58 static PassRefPtr<WorkerThreadableLoader> create(WorkerContext* workerCo ntext, ThreadableLoaderClient* client, const String& taskMode, const ResourceReq uest& request, const ThreadableLoaderOptions& options) 58 static PassRefPtr<WorkerThreadableLoader> create(WorkerGlobalScope* work erGlobalScope, ThreadableLoaderClient* client, const String& taskMode, const Res ourceRequest& request, const ThreadableLoaderOptions& options)
59 { 59 {
60 return adoptRef(new WorkerThreadableLoader(workerContext, client, ta skMode, request, options)); 60 return adoptRef(new WorkerThreadableLoader(workerGlobalScope, client , taskMode, request, options));
61 } 61 }
62 62
63 ~WorkerThreadableLoader(); 63 ~WorkerThreadableLoader();
64 64
65 virtual void cancel() OVERRIDE; 65 virtual void cancel() OVERRIDE;
66 66
67 bool done() const { return m_workerClientWrapper->done(); } 67 bool done() const { return m_workerClientWrapper->done(); }
68 68
69 using RefCounted<WorkerThreadableLoader>::ref; 69 using RefCounted<WorkerThreadableLoader>::ref;
70 using RefCounted<WorkerThreadableLoader>::deref; 70 using RefCounted<WorkerThreadableLoader>::deref;
71 71
72 protected: 72 protected:
73 virtual void refThreadableLoader() OVERRIDE { ref(); } 73 virtual void refThreadableLoader() OVERRIDE { ref(); }
74 virtual void derefThreadableLoader() OVERRIDE { deref(); } 74 virtual void derefThreadableLoader() OVERRIDE { deref(); }
75 75
76 private: 76 private:
77 // Creates a loader on the main thread and bridges communication between 77 // Creates a loader on the main thread and bridges communication between
78 // the main thread and the worker context's thread where WorkerThreadabl eLoader runs. 78 // the main thread and the worker context's thread where WorkerThreadabl eLoader runs.
79 // 79 //
80 // Regarding the bridge and lifetimes of items used in callbacks, there are a few cases: 80 // Regarding the bridge and lifetimes of items used in callbacks, there are a few cases:
81 // 81 //
82 // all cases. All tasks posted from the worker context's thread are ok b ecause 82 // all cases. All tasks posted from the worker context's thread are ok b ecause
83 // the last task posted always is "mainThreadDestroy", so MainThreadB ridge is 83 // the last task posted always is "mainThreadDestroy", so MainThreadB ridge is
84 // around for all tasks that use it on the main thread. 84 // around for all tasks that use it on the main thread.
85 // 85 //
86 // case 1. worker.terminate is called. 86 // case 1. worker.terminate is called.
87 // In this case, no more tasks are posted from the worker object's th read to the worker 87 // In this case, no more tasks are posted from the worker object's th read to the worker
88 // context's thread -- WorkerContextProxy implementation enforces thi s. 88 // context's thread -- WorkerGlobalScopeProxy implementation enforces this.
89 // 89 //
90 // case 2. xhr gets aborted and the worker context continues running. 90 // case 2. xhr gets aborted and the worker context continues running.
91 // The ThreadableLoaderClientWrapper has the underlying client cleare d, so no more calls 91 // The ThreadableLoaderClientWrapper has the underlying client cleare d, so no more calls
92 // go through it. All tasks posted from the worker object's thread t o the worker context's 92 // go through it. All tasks posted from the worker object's thread t o the worker context's
93 // thread do "ThreadableLoaderClientWrapper::ref" (automatically insi de of the cross thread copy 93 // thread do "ThreadableLoaderClientWrapper::ref" (automatically insi de of the cross thread copy
94 // done in createCallbackTask), so the ThreadableLoaderClientWrapper instance is there until all 94 // done in createCallbackTask), so the ThreadableLoaderClientWrapper instance is there until all
95 // tasks are executed. 95 // tasks are executed.
96 class MainThreadBridge : public ThreadableLoaderClient { 96 class MainThreadBridge : public ThreadableLoaderClient {
97 public: 97 public:
98 // All executed on the worker context's thread. 98 // All executed on the worker context's thread.
(...skipping 27 matching lines...) Expand all
126 // The ref counting is done on either thread. 126 // The ref counting is done on either thread.
127 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper; 127 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper;
128 128
129 // May be used on either thread. 129 // May be used on either thread.
130 WorkerLoaderProxy& m_loaderProxy; 130 WorkerLoaderProxy& m_loaderProxy;
131 131
132 // For use on the main thread. 132 // For use on the main thread.
133 String m_taskMode; 133 String m_taskMode;
134 }; 134 };
135 135
136 WorkerThreadableLoader(WorkerContext*, ThreadableLoaderClient*, const St ring& taskMode, const ResourceRequest&, const ThreadableLoaderOptions&); 136 WorkerThreadableLoader(WorkerGlobalScope*, ThreadableLoaderClient*, cons t String& taskMode, const ResourceRequest&, const ThreadableLoaderOptions&);
137 137
138 RefPtr<WorkerContext> m_workerContext; 138 RefPtr<WorkerGlobalScope> m_workerGlobalScope;
139 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper; 139 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper;
140 MainThreadBridge& m_bridge; 140 MainThreadBridge& m_bridge;
141 }; 141 };
142 142
143 } // namespace WebCore 143 } // namespace WebCore
144 144
145 #endif // WorkerThreadableLoader_h 145 #endif // WorkerThreadableLoader_h
OLDNEW
« no previous file with comments | « Source/core/loader/ThreadableLoader.cpp ('k') | Source/core/loader/WorkerThreadableLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698