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

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

Issue 273993002: Allow XHR timeout attribute to be overridden after send(), per spec (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase again Created 6 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
« no previous file with comments | « Source/core/loader/ThreadableLoader.h ('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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
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&, const Resourc eLoaderOptions&); 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, const ResourceLoaderOptions& resourceLoaderOpti ons) 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, resourceLoaderOptions)); 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 overrideTimeout(unsigned long timeout) OVERRIDE;
65
64 virtual void cancel() OVERRIDE; 66 virtual void cancel() OVERRIDE;
65 67
66 private: 68 private:
67 // Creates a loader on the main thread and bridges communication between 69 // Creates a loader on the main thread and bridges communication between
68 // the main thread and the worker context's thread where WorkerThreadabl eLoader runs. 70 // the main thread and the worker context's thread where WorkerThreadabl eLoader runs.
69 // 71 //
70 // Regarding the bridge and lifetimes of items used in callbacks, there are a few cases: 72 // Regarding the bridge and lifetimes of items used in callbacks, there are a few cases:
71 // 73 //
72 // all cases. All tasks posted from the worker context's thread are ok b ecause 74 // all cases. All tasks posted from the worker context's thread are ok b ecause
73 // the last task posted always is "mainThreadDestroy", so MainThreadB ridge is 75 // the last task posted always is "mainThreadDestroy", so MainThreadB ridge is
74 // around for all tasks that use it on the main thread. 76 // around for all tasks that use it on the main thread.
75 // 77 //
76 // case 1. worker.terminate is called. 78 // case 1. worker.terminate is called.
77 // In this case, no more tasks are posted from the worker object's th read to the worker 79 // In this case, no more tasks are posted from the worker object's th read to the worker
78 // context's thread -- WorkerGlobalScopeProxy implementation enforces this. 80 // context's thread -- WorkerGlobalScopeProxy implementation enforces this.
79 // 81 //
80 // case 2. xhr gets aborted and the worker context continues running. 82 // case 2. xhr gets aborted and the worker context continues running.
81 // 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
82 // 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
83 // 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
84 // done in createCrossThreadTask), so the ThreadableLoaderClientWrapp er instance is there until all 86 // done in createCrossThreadTask), so the ThreadableLoaderClientWrapp er instance is there until all
85 // tasks are executed. 87 // tasks are executed.
86 class MainThreadBridge FINAL : public ThreadableLoaderClient { 88 class MainThreadBridge FINAL : public ThreadableLoaderClient {
87 public: 89 public:
88 // All executed on the worker context's thread. 90 // All executed on the worker context's thread.
89 MainThreadBridge(PassRefPtr<ThreadableLoaderClientWrapper>, PassOwnP tr<ThreadableLoaderClient>, WorkerLoaderProxy&, const ResourceRequest&, const Th readableLoaderOptions&, const ResourceLoaderOptions&, const String& outgoingRefe rrer); 91 MainThreadBridge(PassRefPtr<ThreadableLoaderClientWrapper>, PassOwnP tr<ThreadableLoaderClient>, WorkerLoaderProxy&, const ResourceRequest&, const Th readableLoaderOptions&, const ResourceLoaderOptions&, const String& outgoingRefe rrer);
92 void overrideTimeout(unsigned long timeoutMilliseconds);
90 void cancel(); 93 void cancel();
91 void destroy(); 94 void destroy();
92 95
93 private: 96 private:
94 // Executed on the worker context's thread. 97 // Executed on the worker context's thread.
95 void clearClientWrapper(); 98 void clearClientWrapper();
96 99
97 // All executed on the main thread. 100 // All executed on the main thread.
98 static void mainThreadDestroy(ExecutionContext*, MainThreadBridge*); 101 static void mainThreadDestroy(ExecutionContext*, MainThreadBridge*);
99 virtual ~MainThreadBridge(); 102 virtual ~MainThreadBridge();
100 103
101 static void mainThreadCreateLoader(ExecutionContext*, MainThreadBrid ge*, PassOwnPtr<CrossThreadResourceRequestData>, ThreadableLoaderOptions, Resour ceLoaderOptions, const String& outgoingReferrer); 104 static void mainThreadCreateLoader(ExecutionContext*, MainThreadBrid ge*, PassOwnPtr<CrossThreadResourceRequestData>, ThreadableLoaderOptions, Resour ceLoaderOptions, const String& outgoingReferrer);
105 static void mainThreadOverrideTimeout(ExecutionContext*, MainThreadB ridge*, unsigned long timeoutMilliseconds);
102 static void mainThreadCancel(ExecutionContext*, MainThreadBridge*); 106 static void mainThreadCancel(ExecutionContext*, MainThreadBridge*);
103 virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) OVERRIDE; 107 virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) OVERRIDE;
104 virtual void didReceiveResponse(unsigned long identifier, const Reso urceResponse&) OVERRIDE; 108 virtual void didReceiveResponse(unsigned long identifier, const Reso urceResponse&) OVERRIDE;
105 virtual void didReceiveData(const char*, int dataLength) OVERRIDE; 109 virtual void didReceiveData(const char*, int dataLength) OVERRIDE;
106 virtual void didDownloadData(int dataLength) OVERRIDE; 110 virtual void didDownloadData(int dataLength) OVERRIDE;
107 virtual void didReceiveCachedMetadata(const char*, int dataLength) O VERRIDE; 111 virtual void didReceiveCachedMetadata(const char*, int dataLength) O VERRIDE;
108 virtual void didFinishLoading(unsigned long identifier, double finis hTime) OVERRIDE; 112 virtual void didFinishLoading(unsigned long identifier, double finis hTime) OVERRIDE;
109 virtual void didFail(const ResourceError&) OVERRIDE; 113 virtual void didFail(const ResourceError&) OVERRIDE;
110 virtual void didFailAccessControlCheck(const ResourceError&) OVERRID E; 114 virtual void didFailAccessControlCheck(const ResourceError&) OVERRID E;
111 virtual void didFailRedirectCheck() OVERRIDE; 115 virtual void didFailRedirectCheck() OVERRIDE;
(...skipping 13 matching lines...) Expand all
125 WorkerThreadableLoader(WorkerGlobalScope&, PassRefPtr<ThreadableLoaderCl ientWrapper>, PassOwnPtr<ThreadableLoaderClient>, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&); 129 WorkerThreadableLoader(WorkerGlobalScope&, PassRefPtr<ThreadableLoaderCl ientWrapper>, PassOwnPtr<ThreadableLoaderClient>, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
126 130
127 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; 131 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope;
128 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper; 132 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper;
129 MainThreadBridge& m_bridge; 133 MainThreadBridge& m_bridge;
130 }; 134 };
131 135
132 } // namespace blink 136 } // namespace blink
133 137
134 #endif // WorkerThreadableLoader_h 138 #endif // WorkerThreadableLoader_h
OLDNEW
« no previous file with comments | « Source/core/loader/ThreadableLoader.h ('k') | Source/core/loader/WorkerThreadableLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698