Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 // This is a utility class to construct a composite data consumer handle. It | |
| 16 // owns a web data consumer handle and delegates methods. A user can update | |
| 17 // the handle by using |update| method. | |
| 18 class CompositeDataConsumerHandle final : public WebDataConsumerHandle { | |
| 19 public: | |
| 20 // |handle| must not be null and must not be locked. | |
| 21 static PassOwnPtr<CompositeDataConsumerHandle> create(PassOwnPtr<WebDataCons umerHandle> handle) | |
| 22 { | |
| 23 ASSERT(handle); | |
| 24 return adoptPtr(new CompositeDataConsumerHandle(handle)); | |
| 25 } | |
| 26 ~CompositeDataConsumerHandle() override; | |
| 27 | |
| 28 // This function should be called on the thread on which this object | |
| 29 // was created. |handle| must not be null and must not be locked. | |
| 30 void update(PassOwnPtr<WebDataConsumerHandle> /* handle */); | |
| 31 | |
| 32 // Utility static methods each of which provides a "basic block" of | |
| 33 // a CompositeDataConsumerHandle. For example, a user can create | |
| 34 // a CompositeDataConsumerHandle with a "waiting" handle to provide | |
| 35 // WebDataConsumerHandle APIs while waiting for another handle. When that | |
| 36 // handle arrives, the user will use |update| to replace the "waiting" | |
| 37 // handle with the arrived one. | |
| 38 // | |
| 39 // Returns a handle that returns ShouldWait for read / beginRead and | |
| 40 // UnexpectedError for endRead. | |
| 41 static PassOwnPtr<WebDataConsumerHandle> createWaitingHandle(); | |
| 42 | |
| 43 // Returns a handle that returns Done for read / beginRead and | |
| 44 // UnexpectedError for endRead. | |
| 45 static PassOwnPtr<WebDataConsumerHandle> createDoneHandle(); | |
| 46 | |
|
hiroshige
2015/06/10 06:55:26
FYI: createUnexpectedErrorHandle() might be helpfu
| |
| 47 private: | |
| 48 class Context; | |
| 49 class ReaderImpl; | |
| 50 Reader* obtainReaderInternal(Client*) override; | |
| 51 | |
| 52 explicit CompositeDataConsumerHandle(PassOwnPtr<WebDataConsumerHandle>); | |
| 53 | |
| 54 RefPtr<Context> m_context; | |
| 55 }; | |
| 56 | |
| 57 } // namespace blink | |
| 58 | |
| 59 #endif // CompositeDataConsumerHandle_h | |
| OLD | NEW |