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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/CompositeDataConsumerHandle.h

Issue 2342233002: Remove Fetch[Blob|FormData]ConsumerHandle (Closed)
Patch Set: rebase Created 4 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2015 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 CompositeDataConsumerHandle_h
6 #define CompositeDataConsumerHandle_h
7
8 #include "modules/ModulesExport.h"
9 #include "platform/heap/Handle.h"
10 #include "public/platform/WebDataConsumerHandle.h"
11 #include "wtf/Allocator.h"
12 #include "wtf/PtrUtil.h"
13 #include "wtf/RefPtr.h"
14 #include <memory>
15
16 namespace blink {
17
18 class WebThread;
19
20 // This is a utility class to construct a composite data consumer handle. It
21 // owns a web data consumer handle and delegates methods. A user can update
22 // the handle by using |update| method.
23 class MODULES_EXPORT CompositeDataConsumerHandle final : public WebDataConsumerH andle {
24 WTF_MAKE_NONCOPYABLE(CompositeDataConsumerHandle);
25 USING_FAST_MALLOC(CompositeDataConsumerHandle);
26 class Context;
27 public:
28 // An Updater is bound to the creator thread.
29 class MODULES_EXPORT Updater final : public GarbageCollectedFinalized<Update r> {
30 public:
31 explicit Updater(PassRefPtr<Context>);
32 ~Updater();
33
34 // |handle| must not be null and must not be locked.
35 void update(std::unique_ptr<WebDataConsumerHandle> /* handle */);
36 DEFINE_INLINE_TRACE() { }
37
38 private:
39 RefPtr<Context> m_context;
40 #if DCHECK_IS_ON()
41 WebThread* const m_thread;
42 #endif
43 };
44
45 // Returns a handle and stores the associated updater to |*updater|. The
46 // associated updater will be bound to the calling thread.
47 // |handle| must not be null and must not be locked.
48 template<typename T>
49 static std::unique_ptr<WebDataConsumerHandle> create(std::unique_ptr<WebData ConsumerHandle> handle, T* updater)
50 {
51 DCHECK(handle);
52 Updater* u = nullptr;
53 std::unique_ptr<CompositeDataConsumerHandle> p = wrapUnique(new Composit eDataConsumerHandle(std::move(handle), &u));
54 *updater = u;
55 return std::move(p);
56 }
57 ~CompositeDataConsumerHandle() override;
58
59 std::unique_ptr<Reader> obtainReader(Client*) override;
60
61 private:
62 class ReaderImpl;
63
64 const char* debugName() const override { return "CompositeDataConsumerHandle "; }
65
66 CompositeDataConsumerHandle(std::unique_ptr<WebDataConsumerHandle>, Updater* *);
67
68 RefPtr<Context> m_context;
69 };
70
71 } // namespace blink
72
73 #endif // CompositeDataConsumerHandle_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698