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

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

Issue 1162043007: Introduce CompositeDataConsumerHandle. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 "public/platform/WebDataConsumerHandle.h"
9 #include "wtf/OwnPtr.h"
10 #include "wtf/PassOwnPtr.h"
11 #include "wtf/RefPtr.h"
12
13 namespace blink {
14
15 class WebThread;
16
17 // This is a utility class to construct a composite data consumer handle. It
18 // ownes a web data consumer handle and delegates methods. A user can update
hiroshige 2015/06/03 08:45:05 nit: s/ownes/owns/
yhirano 2015/06/04 05:43:02 Done.
19 // the handle by using |update| method.
20 class CompositeDataConsumerHandle final : public WebDataConsumerHandle {
21 public:
22 static PassOwnPtr<CompositeDataConsumerHandle> create(PassOwnPtr<WebDataCons umerHandle> handle)
23 {
24 return adoptPtr(new CompositeDataConsumerHandle(handle));
25 }
26 ~CompositeDataConsumerHandle() override;
27
28 Result read(void* data, size_t /* size */, Flags, size_t* readSize) override ;
29 Result beginRead(const void** buffer, Flags, size_t* available) override;
30 Result endRead(size_t readSize) override;
31 void registerClient(Client* /* client */) override;
32 void unregisterClient() override;
33
34 // This function should be called on the thread on which this object
35 // was created.
hiroshige 2015/06/03 08:45:05 Why does this thread restriction exist? From the c
yhirano 2015/06/04 05:43:02 I would like to leave a future optimization opport
36 void update(PassOwnPtr<WebDataConsumerHandle>);
37
38 // Returns a handle that returns ShouldWait for read / beginRead / endRead
39 // operations.
40 static PassOwnPtr<WebDataConsumerHandle> createWaitingHandle();
hiroshige 2015/06/03 08:45:05 It would be better to add a comment explaining why
yhirano 2015/06/04 05:43:02 Done.
41
42 // Returns a handle that returns Done for read / beginRead / endRead
43 // operations.
44 static PassOwnPtr<WebDataConsumerHandle> createDoneHandle();
45
46 private:
47 explicit CompositeDataConsumerHandle(PassOwnPtr<WebDataConsumerHandle>);
48
49 class MutexHolder;
50 void updateInternal(PassOwnPtr<WebDataConsumerHandle>);
51 static void updateOnTheRightThread(CompositeDataConsumerHandle*, PassOwnPtr< WebDataConsumerHandle>, PassRefPtr<MutexHolder>);
52
53 // TODO(yhirano): Consider using atomic operations instead of mutex if
54 // possible.
55 OwnPtr<WebDataConsumerHandle> m_handle;
56 RefPtr<MutexHolder> m_mutex;
57 Client* m_client;
58 WebThread* m_clientThread;
59 };
60
61 } // namespace blink
62
63 #endif // CompositeDataConsumerHandle_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698