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 CONTENT_CHILD_BODY_CONSUMER_H_ |
| 6 #define CONTENT_CHILD_BODY_CONSUMER_H_ |
| 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 11 #include <utility> |
| 12 #include <vector> |
| 13 |
| 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" |
| 16 #include "content/common/url_loader.mojom.h" |
| 17 #include "mojo/message_pump/handle_watcher.h" |
| 18 #include "mojo/public/cpp/system/data_pipe.h" |
| 19 |
| 20 namespace content { |
| 21 |
| 22 class ResourceDispatcher; |
| 23 |
| 24 class BodyConsumer final : public base::RefCounted<BodyConsumer> { |
| 25 public: |
| 26 BodyConsumer(int request_id, |
| 27 ResourceDispatcher* resource_dispatcher, |
| 28 mojo::ScopedDataPipeConsumerHandle handle); |
| 29 |
| 30 void OnComplete(mojom::URLLoaderStatusPtr status); |
| 31 void Cancel(); |
| 32 |
| 33 private: |
| 34 friend class base::RefCounted<BodyConsumer>; |
| 35 ~BodyConsumer(); |
| 36 |
| 37 class ReceivedData; |
| 38 void Reclaim(uint32_t size); |
| 39 |
| 40 void OnReadable(MojoResult); |
| 41 void StartWatching(); |
| 42 void NotifyCompletionIfAppropriate(); |
| 43 |
| 44 int request_id_; |
| 45 ResourceDispatcher* resource_dispatcher_; |
| 46 mojo::ScopedDataPipeConsumerHandle handle_; |
| 47 mojo::common::HandleWatcher handle_watcher_; |
| 48 mojom::URLLoaderStatusPtr completion_status_; |
| 49 |
| 50 bool has_received_completion_ = false; |
| 51 bool has_been_cancelled_ = false; |
| 52 bool has_seen_end_of_data_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(BodyConsumer); |
| 55 }; |
| 56 |
| 57 } // namespace content |
| 58 |
| 59 #endif // CONTENT_CHILD_BODY_CONSUMER_H_ |
OLD | NEW |