OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef WebAssociatedURLLoaderImpl_h | |
6 #define WebAssociatedURLLoaderImpl_h | |
7 | |
8 #include <memory> | |
9 #include "platform/heap/Handle.h" | |
10 #include "platform/wtf/Noncopyable.h" | |
11 #include "platform/wtf/RefPtr.h" | |
12 #include "public/web/WebAssociatedURLLoader.h" | |
13 #include "public/web/WebAssociatedURLLoaderOptions.h" | |
14 | |
15 namespace blink { | |
16 | |
17 class DocumentThreadableLoader; | |
18 class WebAssociatedURLLoaderClient; | |
19 class WebLocalFrameImpl; | |
20 | |
21 // This class is used to implement WebFrame::createAssociatedURLLoader. | |
22 class WebAssociatedURLLoaderImpl final : public WebAssociatedURLLoader { | |
23 WTF_MAKE_NONCOPYABLE(WebAssociatedURLLoaderImpl); | |
24 | |
25 public: | |
26 WebAssociatedURLLoaderImpl(WebLocalFrameImpl*, | |
27 const WebAssociatedURLLoaderOptions&); | |
28 ~WebAssociatedURLLoaderImpl(); | |
29 | |
30 void LoadAsynchronously(const WebURLRequest&, | |
31 WebAssociatedURLLoaderClient*) override; | |
32 void Cancel() override; | |
33 void SetDefersLoading(bool) override; | |
34 void SetLoadingTaskRunner(blink::WebTaskRunner*) override; | |
35 | |
36 // Called by |m_observer| to handle destruction of the Document associated | |
37 // with the frame given to the constructor. | |
38 void DocumentDestroyed(); | |
39 | |
40 // Called by ClientAdapter to handle completion of loading. | |
41 void ClientAdapterDone(); | |
42 | |
43 private: | |
44 class ClientAdapter; | |
45 class Observer; | |
46 | |
47 void CancelLoader(); | |
48 void DisposeObserver(); | |
49 | |
50 WebAssociatedURLLoaderClient* ReleaseClient() { | |
51 WebAssociatedURLLoaderClient* client = client_; | |
52 client_ = nullptr; | |
53 return client; | |
54 } | |
55 | |
56 WebAssociatedURLLoaderClient* client_; | |
57 WebAssociatedURLLoaderOptions options_; | |
58 | |
59 // An adapter which converts the DocumentThreadableLoaderClient method | |
60 // calls into the WebURLLoaderClient method calls. | |
61 std::unique_ptr<ClientAdapter> client_adapter_; | |
62 Persistent<DocumentThreadableLoader> loader_; | |
63 | |
64 // A ContextLifecycleObserver for cancelling |m_loader| when the Document | |
65 // is detached. | |
66 Persistent<Observer> observer_; | |
67 }; | |
68 | |
69 } // namespace blink | |
70 | |
71 #endif | |
OLD | NEW |