| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/child/url_response_body_consumer.h" | 5 #include "content/child/url_response_body_consumer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "content/child/resource_dispatcher.h" | 10 #include "content/child/resource_dispatcher.h" |
| 11 #include "content/common/resource_messages.h" | 11 #include "content/common/resource_messages.h" |
| 12 #include "content/common/resource_request_completion_status.h" | 12 #include "content/common/resource_request_completion_status.h" |
| 13 #include "content/public/child/request_peer.h" | 13 #include "content/public/child/request_peer.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 class URLResponseBodyConsumer::ReceivedData final | 17 class URLResponseBodyConsumer::ReceivedData final |
| 18 : public RequestPeer::ReceivedData { | 18 : public RequestPeer::ReceivedData { |
| 19 public: | 19 public: |
| 20 ReceivedData(const char* payload, | 20 ReceivedData(const char* payload, |
| 21 int length, | 21 int length, |
| 22 scoped_refptr<URLResponseBodyConsumer> consumer) | 22 scoped_refptr<URLResponseBodyConsumer> consumer) |
| 23 : payload_(payload), length_(length), consumer_(consumer) {} | 23 : payload_(payload), length_(length), consumer_(consumer) {} |
| 24 | 24 |
| 25 ~ReceivedData() override { consumer_->Reclaim(length_); } | 25 ~ReceivedData() override { consumer_->Reclaim(length_); } |
| 26 | 26 |
| 27 const char* payload() const override { return payload_; } | 27 const char* payload() const override { return payload_; } |
| 28 int length() const override { return length_; } | 28 int length() const override { return length_; } |
| 29 // TODO(yhirano): These return incorrect values. Remove these from | 29 // TODO(yhirano): This returns an incorrect value. Remove it from |
| 30 // ReceivedData before enabling Mojo-Loading. | 30 // ReceivedData before enabling Mojo-Loading. |
| 31 int encoded_data_length() const override { return length_; } | 31 int encoded_data_length() const override { return length_; } |
| 32 int encoded_body_length() const override { return length_; } | |
| 33 | 32 |
| 34 private: | 33 private: |
| 35 const char* const payload_; | 34 const char* const payload_; |
| 36 const uint32_t length_; | 35 const uint32_t length_; |
| 37 | 36 |
| 38 scoped_refptr<URLResponseBodyConsumer> consumer_; | 37 scoped_refptr<URLResponseBodyConsumer> consumer_; |
| 39 | 38 |
| 40 DISALLOW_COPY_AND_ASSIGN(ReceivedData); | 39 DISALLOW_COPY_AND_ASSIGN(ReceivedData); |
| 41 }; | 40 }; |
| 42 | 41 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return; | 124 return; |
| 126 // Cancel this instance in order not to notify twice. | 125 // Cancel this instance in order not to notify twice. |
| 127 Cancel(); | 126 Cancel(); |
| 128 | 127 |
| 129 resource_dispatcher_->OnMessageReceived( | 128 resource_dispatcher_->OnMessageReceived( |
| 130 ResourceMsg_RequestComplete(request_id_, completion_status_)); | 129 ResourceMsg_RequestComplete(request_id_, completion_status_)); |
| 131 // |this| may be deleted. | 130 // |this| may be deleted. |
| 132 } | 131 } |
| 133 | 132 |
| 134 } // namespace content | 133 } // namespace content |
| OLD | NEW |