| OLD | NEW |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "platform/wtf/text/WTFString.h" | 45 #include "platform/wtf/text/WTFString.h" |
| 46 #include "public/platform/WebTraceLocation.h" | 46 #include "public/platform/WebTraceLocation.h" |
| 47 | 47 |
| 48 namespace blink { | 48 namespace blink { |
| 49 | 49 |
| 50 class ThreadableLoadingContext; | 50 class ThreadableLoadingContext; |
| 51 class ResourceError; | 51 class ResourceError; |
| 52 class ResourceRequest; | 52 class ResourceRequest; |
| 53 class ResourceResponse; | 53 class ResourceResponse; |
| 54 class WorkerGlobalScope; | 54 class WorkerGlobalScope; |
| 55 class WorkerLoaderProxy; | |
| 56 struct CrossThreadResourceRequestData; | 55 struct CrossThreadResourceRequestData; |
| 57 struct CrossThreadResourceTimingInfoData; | 56 struct CrossThreadResourceTimingInfoData; |
| 58 | 57 |
| 59 // A WorkerThreadableLoader is a ThreadableLoader implementation intended to | 58 // A WorkerThreadableLoader is a ThreadableLoader implementation intended to |
| 60 // be used in a WebWorker thread. Because Blink's ResourceFetcher and | 59 // be used in a WebWorker thread. Because Blink's ResourceFetcher and |
| 61 // ResourceLoader work only in the main thread, a WorkerThreadableLoader holds | 60 // ResourceLoader work only in the main thread, a WorkerThreadableLoader holds |
| 62 // a ThreadableLoader in the main thread and delegates tasks asynchronously | 61 // a ThreadableLoader in the main thread and delegates tasks asynchronously |
| 63 // to the loader. | 62 // to the loader. |
| 64 // | 63 // |
| 65 // CTP: CrossThreadPersistent | 64 // CTP: CrossThreadPersistent |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // worker thread. | 133 // worker thread. |
| 135 class MainThreadLoaderHolder final | 134 class MainThreadLoaderHolder final |
| 136 : public GarbageCollectedFinalized<MainThreadLoaderHolder>, | 135 : public GarbageCollectedFinalized<MainThreadLoaderHolder>, |
| 137 public ThreadableLoaderClient, | 136 public ThreadableLoaderClient, |
| 138 public WorkerThreadLifecycleObserver { | 137 public WorkerThreadLifecycleObserver { |
| 139 USING_GARBAGE_COLLECTED_MIXIN(MainThreadLoaderHolder); | 138 USING_GARBAGE_COLLECTED_MIXIN(MainThreadLoaderHolder); |
| 140 USING_PRE_FINALIZER(MainThreadLoaderHolder, Cancel); | 139 USING_PRE_FINALIZER(MainThreadLoaderHolder, Cancel); |
| 141 | 140 |
| 142 public: | 141 public: |
| 143 static void CreateAndStart(WorkerThreadableLoader*, | 142 static void CreateAndStart(WorkerThreadableLoader*, |
| 144 RefPtr<WorkerLoaderProxy>, | 143 ThreadableLoadingContext*, |
| 145 RefPtr<WebTaskRunner>, | 144 RefPtr<WebTaskRunner>, |
| 146 WorkerThreadLifecycleContext*, | 145 WorkerThreadLifecycleContext*, |
| 147 std::unique_ptr<CrossThreadResourceRequestData>, | 146 std::unique_ptr<CrossThreadResourceRequestData>, |
| 148 const ThreadableLoaderOptions&, | 147 const ThreadableLoaderOptions&, |
| 149 const ResourceLoaderOptions&, | 148 const ResourceLoaderOptions&, |
| 150 PassRefPtr<WaitableEventWithTasks>); | 149 PassRefPtr<WaitableEventWithTasks>); |
| 151 ~MainThreadLoaderHolder() override; | 150 ~MainThreadLoaderHolder() override; |
| 152 | 151 |
| 153 void OverrideTimeout(unsigned long timeout_millisecond); | 152 void OverrideTimeout(unsigned long timeout_millisecond); |
| 154 void Cancel(); | 153 void Cancel(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 void DidReceiveCachedMetadata(std::unique_ptr<Vector<char>> data); | 203 void DidReceiveCachedMetadata(std::unique_ptr<Vector<char>> data); |
| 205 void DidFinishLoading(unsigned long identifier, double finish_time); | 204 void DidFinishLoading(unsigned long identifier, double finish_time); |
| 206 void DidFail(const ResourceError&); | 205 void DidFail(const ResourceError&); |
| 207 void DidFailAccessControlCheck(const ResourceError&); | 206 void DidFailAccessControlCheck(const ResourceError&); |
| 208 void DidFailRedirectCheck(); | 207 void DidFailRedirectCheck(); |
| 209 void DidDownloadData(int data_length); | 208 void DidDownloadData(int data_length); |
| 210 void DidReceiveResourceTiming( | 209 void DidReceiveResourceTiming( |
| 211 std::unique_ptr<CrossThreadResourceTimingInfoData>); | 210 std::unique_ptr<CrossThreadResourceTimingInfoData>); |
| 212 | 211 |
| 213 Member<WorkerGlobalScope> worker_global_scope_; | 212 Member<WorkerGlobalScope> worker_global_scope_; |
| 214 RefPtr<WorkerLoaderProxy> worker_loader_proxy_; | |
| 215 CrossThreadPersistent<ParentFrameTaskRunners> parent_frame_task_runners_; | 213 CrossThreadPersistent<ParentFrameTaskRunners> parent_frame_task_runners_; |
| 216 ThreadableLoaderClient* client_; | 214 ThreadableLoaderClient* client_; |
| 217 | 215 |
| 218 ThreadableLoaderOptions threadable_loader_options_; | 216 ThreadableLoaderOptions threadable_loader_options_; |
| 219 ResourceLoaderOptions resource_loader_options_; | 217 ResourceLoaderOptions resource_loader_options_; |
| 220 BlockingBehavior blocking_behavior_; | 218 BlockingBehavior blocking_behavior_; |
| 221 | 219 |
| 222 // |*m_mainThreadLoaderHolder| lives in the main thread. | 220 // |*m_mainThreadLoaderHolder| lives in the main thread. |
| 223 CrossThreadPersistent<MainThreadLoaderHolder> main_thread_loader_holder_; | 221 CrossThreadPersistent<MainThreadLoaderHolder> main_thread_loader_holder_; |
| 224 }; | 222 }; |
| 225 | 223 |
| 226 } // namespace blink | 224 } // namespace blink |
| 227 | 225 |
| 228 #endif // WorkerThreadableLoader_h | 226 #endif // WorkerThreadableLoader_h |
| OLD | NEW |