| 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): This returns an incorrect value. Remove it from | |
| 30 // ReceivedData before enabling Mojo-Loading. | |
| 31 int encoded_data_length() const override { return length_; } | |
| 32 | 29 |
| 33 private: | 30 private: |
| 34 const char* const payload_; | 31 const char* const payload_; |
| 35 const uint32_t length_; | 32 const uint32_t length_; |
| 36 | 33 |
| 37 scoped_refptr<URLResponseBodyConsumer> consumer_; | 34 scoped_refptr<URLResponseBodyConsumer> consumer_; |
| 38 | 35 |
| 39 DISALLOW_COPY_AND_ASSIGN(ReceivedData); | 36 DISALLOW_COPY_AND_ASSIGN(ReceivedData); |
| 40 }; | 37 }; |
| 41 | 38 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return; | 121 return; |
| 125 // Cancel this instance in order not to notify twice. | 122 // Cancel this instance in order not to notify twice. |
| 126 Cancel(); | 123 Cancel(); |
| 127 | 124 |
| 128 resource_dispatcher_->OnMessageReceived( | 125 resource_dispatcher_->OnMessageReceived( |
| 129 ResourceMsg_RequestComplete(request_id_, completion_status_)); | 126 ResourceMsg_RequestComplete(request_id_, completion_status_)); |
| 130 // |this| may be deleted. | 127 // |this| may be deleted. |
| 131 } | 128 } |
| 132 | 129 |
| 133 } // namespace content | 130 } // namespace content |
| OLD | NEW |