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

Side by Side Diff: Source/core/loader/WorkerThreadableLoader.h

Issue 301243015: Refactor ThreadableLoaderOptions for readability (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 class ResourceError; 46 class ResourceError;
47 class ResourceRequest; 47 class ResourceRequest;
48 class WorkerGlobalScope; 48 class WorkerGlobalScope;
49 class WorkerLoaderProxy; 49 class WorkerLoaderProxy;
50 struct CrossThreadResourceResponseData; 50 struct CrossThreadResourceResponseData;
51 struct CrossThreadResourceRequestData; 51 struct CrossThreadResourceRequestData;
52 52
53 class WorkerThreadableLoader FINAL : public ThreadableLoader { 53 class WorkerThreadableLoader FINAL : public ThreadableLoader {
54 WTF_MAKE_FAST_ALLOCATED; 54 WTF_MAKE_FAST_ALLOCATED;
55 public: 55 public:
56 static void loadResourceSynchronously(WorkerGlobalScope&, const Resource Request&, ThreadableLoaderClient&, const ThreadableLoaderOptions&); 56 static void loadResourceSynchronously(WorkerGlobalScope&, const Resource Request&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const Resourc eLoaderOptions&);
57 static PassRefPtr<WorkerThreadableLoader> create(WorkerGlobalScope& work erGlobalScope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnP tr<ThreadableLoaderClient> clientBridge, const ResourceRequest& request, const T hreadableLoaderOptions& options) 57 static PassRefPtr<WorkerThreadableLoader> create(WorkerGlobalScope& work erGlobalScope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnP tr<ThreadableLoaderClient> clientBridge, const ResourceRequest& request, const T hreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderOpti ons)
58 { 58 {
59 return adoptRef(new WorkerThreadableLoader(workerGlobalScope, client Wrapper, clientBridge, request, options)); 59 return adoptRef(new WorkerThreadableLoader(workerGlobalScope, client Wrapper, clientBridge, request, options, resourceLoaderOptions));
60 } 60 }
61 61
62 virtual ~WorkerThreadableLoader(); 62 virtual ~WorkerThreadableLoader();
63 63
64 virtual void cancel() OVERRIDE; 64 virtual void cancel() OVERRIDE;
65 65
66 bool done() const { return m_workerClientWrapper->done(); } 66 bool done() const { return m_workerClientWrapper->done(); }
67 67
68 private: 68 private:
69 // Creates a loader on the main thread and bridges communication between 69 // Creates a loader on the main thread and bridges communication between
(...skipping 11 matching lines...) Expand all
81 // 81 //
82 // case 2. xhr gets aborted and the worker context continues running. 82 // case 2. xhr gets aborted and the worker context continues running.
83 // The ThreadableLoaderClientWrapper has the underlying client cleare d, so no more calls 83 // The ThreadableLoaderClientWrapper has the underlying client cleare d, so no more calls
84 // go through it. All tasks posted from the worker object's thread t o the worker context's 84 // go through it. All tasks posted from the worker object's thread t o the worker context's
85 // thread do "ThreadableLoaderClientWrapper::ref" (automatically insi de of the cross thread copy 85 // thread do "ThreadableLoaderClientWrapper::ref" (automatically insi de of the cross thread copy
86 // done in createCallbackTask), so the ThreadableLoaderClientWrapper instance is there until all 86 // done in createCallbackTask), so the ThreadableLoaderClientWrapper instance is there until all
87 // tasks are executed. 87 // tasks are executed.
88 class MainThreadBridge FINAL : public ThreadableLoaderClient { 88 class MainThreadBridge FINAL : public ThreadableLoaderClient {
89 public: 89 public:
90 // All executed on the worker context's thread. 90 // All executed on the worker context's thread.
91 MainThreadBridge(PassRefPtr<ThreadableLoaderClientWrapper>, PassOwnP tr<ThreadableLoaderClient>, WorkerLoaderProxy&, const ResourceRequest&, const Th readableLoaderOptions&, const String& outgoingReferrer); 91 MainThreadBridge(PassRefPtr<ThreadableLoaderClientWrapper>, PassOwnP tr<ThreadableLoaderClient>, WorkerLoaderProxy&, const ResourceRequest&, const Th readableLoaderOptions&, const ResourceLoaderOptions&, const String& outgoingRefe rrer);
92 void cancel(); 92 void cancel();
93 void destroy(); 93 void destroy();
94 94
95 private: 95 private:
96 // Executed on the worker context's thread. 96 // Executed on the worker context's thread.
97 void clearClientWrapper(); 97 void clearClientWrapper();
98 98
99 // All executed on the main thread. 99 // All executed on the main thread.
100 static void mainThreadDestroy(ExecutionContext*, MainThreadBridge*); 100 static void mainThreadDestroy(ExecutionContext*, MainThreadBridge*);
101 virtual ~MainThreadBridge(); 101 virtual ~MainThreadBridge();
102 102
103 static void mainThreadCreateLoader(ExecutionContext*, MainThreadBrid ge*, PassOwnPtr<CrossThreadResourceRequestData>, ThreadableLoaderOptions, const String& outgoingReferrer); 103 static void mainThreadCreateLoader(ExecutionContext*, MainThreadBrid ge*, PassOwnPtr<CrossThreadResourceRequestData>, ThreadableLoaderOptions, Resour ceLoaderOptions, const String& outgoingReferrer);
104 static void mainThreadCancel(ExecutionContext*, MainThreadBridge*); 104 static void mainThreadCancel(ExecutionContext*, MainThreadBridge*);
105 virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) OVERRIDE; 105 virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) OVERRIDE;
106 virtual void didReceiveResponse(unsigned long identifier, const Reso urceResponse&) OVERRIDE; 106 virtual void didReceiveResponse(unsigned long identifier, const Reso urceResponse&) OVERRIDE;
107 virtual void didReceiveData(const char*, int dataLength) OVERRIDE; 107 virtual void didReceiveData(const char*, int dataLength) OVERRIDE;
108 virtual void didDownloadData(int dataLength) OVERRIDE; 108 virtual void didDownloadData(int dataLength) OVERRIDE;
109 virtual void didReceiveCachedMetadata(const char*, int dataLength) O VERRIDE; 109 virtual void didReceiveCachedMetadata(const char*, int dataLength) O VERRIDE;
110 virtual void didFinishLoading(unsigned long identifier, double finis hTime) OVERRIDE; 110 virtual void didFinishLoading(unsigned long identifier, double finis hTime) OVERRIDE;
111 virtual void didFail(const ResourceError&) OVERRIDE; 111 virtual void didFail(const ResourceError&) OVERRIDE;
112 virtual void didFailAccessControlCheck(const ResourceError&) OVERRID E; 112 virtual void didFailAccessControlCheck(const ResourceError&) OVERRID E;
113 virtual void didFailRedirectCheck() OVERRIDE; 113 virtual void didFailRedirectCheck() OVERRIDE;
114 114
115 // Only to be used on the main thread. 115 // Only to be used on the main thread.
116 RefPtr<ThreadableLoader> m_mainThreadLoader; 116 RefPtr<ThreadableLoader> m_mainThreadLoader;
117 OwnPtr<ThreadableLoaderClient> m_clientBridge; 117 OwnPtr<ThreadableLoaderClient> m_clientBridge;
118 118
119 // ThreadableLoaderClientWrapper is to be used on the worker context thread. 119 // ThreadableLoaderClientWrapper is to be used on the worker context thread.
120 // The ref counting is done on either thread. 120 // The ref counting is done on either thread.
121 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper; 121 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper;
122 122
123 // Used on the worker context thread. 123 // Used on the worker context thread.
124 WorkerLoaderProxy& m_loaderProxy; 124 WorkerLoaderProxy& m_loaderProxy;
125 }; 125 };
126 126
127 WorkerThreadableLoader(WorkerGlobalScope&, PassRefPtr<ThreadableLoaderCl ientWrapper>, PassOwnPtr<ThreadableLoaderClient>, const ResourceRequest&, const ThreadableLoaderOptions&); 127 WorkerThreadableLoader(WorkerGlobalScope&, PassRefPtr<ThreadableLoaderCl ientWrapper>, PassOwnPtr<ThreadableLoaderClient>, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
128 128
129 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; 129 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope;
130 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper; 130 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper;
131 MainThreadBridge& m_bridge; 131 MainThreadBridge& m_bridge;
132 }; 132 };
133 133
134 } // namespace WebCore 134 } // namespace WebCore
135 135
136 #endif // WorkerThreadableLoader_h 136 #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