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

Side by Side Diff: Source/modules/fetch/FetchManager.cpp

Issue 1233173002: Have ScriptPromiseResolver on the Oilpan heap always. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix webusb ScriptPromiseResolver usage Created 5 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/modules/fetch/Body.cpp ('k') | Source/modules/geofencing/Geofencing.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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/fetch/FetchManager.h" 6 #include "modules/fetch/FetchManager.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 22 matching lines...) Expand all
33 #include "platform/network/ResourceResponse.h" 33 #include "platform/network/ResourceResponse.h"
34 #include "platform/weborigin/SecurityOrigin.h" 34 #include "platform/weborigin/SecurityOrigin.h"
35 #include "public/platform/WebURLRequest.h" 35 #include "public/platform/WebURLRequest.h"
36 #include "wtf/HashSet.h" 36 #include "wtf/HashSet.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 class FetchManager::Loader final : public NoBaseWillBeGarbageCollectedFinalized< FetchManager::Loader>, public ThreadableLoaderClient, public ContextLifecycleObs erver { 40 class FetchManager::Loader final : public NoBaseWillBeGarbageCollectedFinalized< FetchManager::Loader>, public ThreadableLoaderClient, public ContextLifecycleObs erver {
41 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(FetchManager::Loader); 41 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(FetchManager::Loader);
42 public: 42 public:
43 static PassOwnPtrWillBeRawPtr<Loader> create(ExecutionContext* executionCont ext, FetchManager* fetchManager, PassRefPtrWillBeRawPtr<ScriptPromiseResolver> r esolver, FetchRequestData* request) 43 static PassOwnPtrWillBeRawPtr<Loader> create(ExecutionContext* executionCont ext, FetchManager* fetchManager, ScriptPromiseResolver* resolver, FetchRequestDa ta* request)
44 { 44 {
45 return adoptPtrWillBeNoop(new Loader(executionContext, fetchManager, res olver, request)); 45 return adoptPtrWillBeNoop(new Loader(executionContext, fetchManager, res olver, request));
46 } 46 }
47 47
48 ~Loader() override; 48 ~Loader() override;
49 DECLARE_VIRTUAL_TRACE(); 49 DECLARE_VIRTUAL_TRACE();
50 50
51 void didReceiveResponse(unsigned long, const ResourceResponse&, PassOwnPtr<W ebDataConsumerHandle>) override; 51 void didReceiveResponse(unsigned long, const ResourceResponse&, PassOwnPtr<W ebDataConsumerHandle>) override;
52 void didFinishLoading(unsigned long, double) override; 52 void didFinishLoading(unsigned long, double) override;
53 void didFail(const ResourceError&) override; 53 void didFail(const ResourceError&) override;
54 void didFailAccessControlCheck(const ResourceError&) override; 54 void didFailAccessControlCheck(const ResourceError&) override;
55 void didFailRedirectCheck() override; 55 void didFailRedirectCheck() override;
56 56
57 void start(); 57 void start();
58 void dispose(); 58 void dispose();
59 59
60 private: 60 private:
61 Loader(ExecutionContext*, FetchManager*, PassRefPtrWillBeRawPtr<ScriptPromis eResolver>, FetchRequestData*); 61 Loader(ExecutionContext*, FetchManager*, ScriptPromiseResolver*, FetchReques tData*);
62 62
63 void performBasicFetch(); 63 void performBasicFetch();
64 void performNetworkError(const String& message); 64 void performNetworkError(const String& message);
65 void performHTTPFetch(bool corsFlag, bool corsPreflightFlag); 65 void performHTTPFetch(bool corsFlag, bool corsPreflightFlag);
66 void failed(const String& message); 66 void failed(const String& message);
67 void notifyFinished(); 67 void notifyFinished();
68 Document* document() const; 68 Document* document() const;
69 69
70 RawPtrWillBeMember<FetchManager> m_fetchManager; 70 RawPtrWillBeMember<FetchManager> m_fetchManager;
71 RefPtrWillBeMember<ScriptPromiseResolver> m_resolver; 71 PersistentWillBeMember<ScriptPromiseResolver> m_resolver;
72 PersistentWillBeMember<FetchRequestData> m_request; 72 PersistentWillBeMember<FetchRequestData> m_request;
73 RefPtr<ThreadableLoader> m_loader; 73 RefPtr<ThreadableLoader> m_loader;
74 bool m_failed; 74 bool m_failed;
75 bool m_finished; 75 bool m_finished;
76 int m_responseHttpStatusCode; 76 int m_responseHttpStatusCode;
77 }; 77 };
78 78
79 FetchManager::Loader::Loader(ExecutionContext* executionContext, FetchManager* f etchManager, PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver, FetchReques tData* request) 79 FetchManager::Loader::Loader(ExecutionContext* executionContext, FetchManager* f etchManager, ScriptPromiseResolver* resolver, FetchRequestData* request)
80 : ContextLifecycleObserver(executionContext) 80 : ContextLifecycleObserver(executionContext)
81 , m_fetchManager(fetchManager) 81 , m_fetchManager(fetchManager)
82 , m_resolver(resolver) 82 , m_resolver(resolver)
83 , m_request(request) 83 , m_request(request)
84 , m_failed(false) 84 , m_failed(false)
85 , m_finished(false) 85 , m_finished(false)
86 , m_responseHttpStatusCode(0) 86 , m_responseHttpStatusCode(0)
87 { 87 {
88 } 88 }
89 89
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 FetchManager::~FetchManager() 421 FetchManager::~FetchManager()
422 { 422 {
423 #if !ENABLE(OILPAN) 423 #if !ENABLE(OILPAN)
424 if (!m_isStopped) 424 if (!m_isStopped)
425 stop(); 425 stop();
426 #endif 426 #endif
427 } 427 }
428 428
429 ScriptPromise FetchManager::fetch(ScriptState* scriptState, FetchRequestData* re quest) 429 ScriptPromise FetchManager::fetch(ScriptState* scriptState, FetchRequestData* re quest)
430 { 430 {
431 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 431 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
432 ScriptPromise promise = resolver->promise(); 432 ScriptPromise promise = resolver->promise();
433 433
434 request->setContext(WebURLRequest::RequestContextFetch); 434 request->setContext(WebURLRequest::RequestContextFetch);
435 435
436 OwnPtrWillBeRawPtr<Loader> ownLoader = Loader::create(m_executionContext, th is, resolver.release(), request); 436 OwnPtrWillBeRawPtr<Loader> ownLoader = Loader::create(m_executionContext, th is, resolver, request);
437 Loader* loader = m_loaders.add(ownLoader.release()).storedValue->get(); 437 Loader* loader = m_loaders.add(ownLoader.release()).storedValue->get();
438 loader->start(); 438 loader->start();
439 return promise; 439 return promise;
440 } 440 }
441 441
442 void FetchManager::stop() 442 void FetchManager::stop()
443 { 443 {
444 ASSERT(!m_isStopped); 444 ASSERT(!m_isStopped);
445 m_isStopped = true; 445 m_isStopped = true;
446 for (auto& loader : m_loaders) 446 for (auto& loader : m_loaders)
(...skipping 10 matching lines...) Expand all
457 457
458 DEFINE_TRACE(FetchManager) 458 DEFINE_TRACE(FetchManager)
459 { 459 {
460 #if ENABLE(OILPAN) 460 #if ENABLE(OILPAN)
461 visitor->trace(m_executionContext); 461 visitor->trace(m_executionContext);
462 visitor->trace(m_loaders); 462 visitor->trace(m_loaders);
463 #endif 463 #endif
464 } 464 }
465 465
466 } // namespace blink 466 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/fetch/Body.cpp ('k') | Source/modules/geofencing/Geofencing.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698