OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/web_data_consumer_handle_impl.h" | 5 #include "content/child/web_data_consumer_handle_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 void ReadMore() override { | 73 void ReadMore() override { |
74 // We may have drained the pipe while this task was waiting to run. | 74 // We may have drained the pipe while this task was waiting to run. |
75 if (reader_) | 75 if (reader_) |
76 ReadData(); | 76 ReadData(); |
77 } | 77 } |
78 | 78 |
79 void ReadData() { | 79 void ReadData() { |
80 if (!client_) { | 80 if (!client_) { |
81 client_.reset(new ClientImpl(this)); | 81 client_.reset(new ClientImpl(this)); |
82 reader_ = handle_->ObtainReader(client_.get()); | 82 reader_ = handle_->obtainReader(client_.get()); |
83 } | 83 } |
84 | 84 |
85 Result rv = kOk; | 85 Result rv = kOk; |
86 size_t readSize = 0; | 86 size_t readSize = 0; |
87 while (true) { | 87 while (true) { |
88 char buffer[16]; | 88 char buffer[16]; |
89 rv = reader_->read(&buffer, sizeof(buffer), kNone, &readSize); | 89 rv = reader_->read(&buffer, sizeof(buffer), kNone, &readSize); |
90 if (rv != kOk) | 90 if (rv != kOk) |
91 break; | 91 break; |
92 result_.insert(result_.size(), &buffer[0], readSize); | 92 result_.insert(result_.size(), &buffer[0], readSize); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 void ReadMore() override { | 131 void ReadMore() override { |
132 // We may have drained the pipe while this task was waiting to run. | 132 // We may have drained the pipe while this task was waiting to run. |
133 if (reader_) | 133 if (reader_) |
134 ReadData(); | 134 ReadData(); |
135 } | 135 } |
136 | 136 |
137 void ReadData() { | 137 void ReadData() { |
138 if (!client_) { | 138 if (!client_) { |
139 client_.reset(new ClientImpl(this)); | 139 client_.reset(new ClientImpl(this)); |
140 reader_ = handle_->ObtainReader(client_.get()); | 140 reader_ = handle_->obtainReader(client_.get()); |
141 } | 141 } |
142 | 142 |
143 Result rv; | 143 Result rv; |
144 while (true) { | 144 while (true) { |
145 const void* buffer = nullptr; | 145 const void* buffer = nullptr; |
146 size_t size; | 146 size_t size; |
147 rv = reader_->beginRead(&buffer, kNone, &size); | 147 rv = reader_->beginRead(&buffer, kNone, &size); |
148 if (rv != kOk) | 148 if (rv != kOk) |
149 break; | 149 break; |
150 // In order to verify endRead, we read at most one byte for each time. | 150 // In order to verify endRead, we read at most one byte for each time. |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 272 |
273 run_loop.Run(); | 273 run_loop.Run(); |
274 t.Stop(); | 274 t.Stop(); |
275 | 275 |
276 EXPECT_EQ(expected, operation->result()); | 276 EXPECT_EQ(expected, operation->result()); |
277 } | 277 } |
278 | 278 |
279 } // namespace | 279 } // namespace |
280 | 280 |
281 } // namespace content | 281 } // namespace content |
OLD | NEW |