OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "public/platform/WebDataConsumerHandle.h" | 5 #include "public/platform/WebDataConsumerHandle.h" |
6 | 6 |
| 7 #include <string.h> |
| 8 #include <algorithm> |
| 9 #include <memory> |
7 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
8 #include "wtf/PtrUtil.h" | 11 #include "wtf/PtrUtil.h" |
9 #include <algorithm> | |
10 #include <memory> | |
11 #include <string.h> | |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 WebDataConsumerHandle::WebDataConsumerHandle() { | 15 WebDataConsumerHandle::WebDataConsumerHandle() { |
16 ASSERT(ThreadState::current()); | 16 ASSERT(ThreadState::current()); |
17 } | 17 } |
18 | 18 |
19 WebDataConsumerHandle::~WebDataConsumerHandle() { | 19 WebDataConsumerHandle::~WebDataConsumerHandle() { |
20 ASSERT(ThreadState::current()); | 20 ASSERT(ThreadState::current()); |
21 } | 21 } |
22 | 22 |
23 WebDataConsumerHandle::Result WebDataConsumerHandle::Reader::read( | 23 WebDataConsumerHandle::Result WebDataConsumerHandle::Reader::read( |
24 void* data, | 24 void* data, |
25 size_t size, | 25 size_t size, |
26 Flags flags, | 26 Flags flags, |
27 size_t* readSize) { | 27 size_t* readSize) { |
28 *readSize = 0; | 28 *readSize = 0; |
29 const void* src = nullptr; | 29 const void* src = nullptr; |
30 size_t available; | 30 size_t available; |
31 Result r = beginRead(&src, flags, &available); | 31 Result r = beginRead(&src, flags, &available); |
32 if (r != WebDataConsumerHandle::Ok) | 32 if (r != WebDataConsumerHandle::Ok) |
33 return r; | 33 return r; |
34 *readSize = std::min(available, size); | 34 *readSize = std::min(available, size); |
35 memcpy(data, src, *readSize); | 35 memcpy(data, src, *readSize); |
36 return endRead(*readSize); | 36 return endRead(*readSize); |
37 } | 37 } |
38 | 38 |
39 } // namespace blink | 39 } // namespace blink |
OLD | NEW |