OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome_frame/urlmon_upload_data_stream.h" | 5 #include "chrome_frame/urlmon_upload_data_stream.h" |
6 | 6 |
7 #include "net/base/io_buffer.h" | 7 #include "net/base/io_buffer.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 | 9 |
10 void UrlmonUploadDataStream::Initialize(net::UploadData* upload_data) { | 10 void UrlmonUploadDataStream::Initialize(net::UploadData* upload_data) { |
(...skipping 23 matching lines...) Expand all Loading... |
34 uint64 total_bytes_to_copy = cb; | 34 uint64 total_bytes_to_copy = cb; |
35 | 35 |
36 uint64 bytes_copied = 0; | 36 uint64 bytes_copied = 0; |
37 | 37 |
38 char* write_pointer = reinterpret_cast<char*>(pv); | 38 char* write_pointer = reinterpret_cast<char*>(pv); |
39 while (bytes_copied < total_bytes_to_copy) { | 39 while (bytes_copied < total_bytes_to_copy) { |
40 size_t bytes_to_copy_now = total_bytes_to_copy - bytes_copied; | 40 size_t bytes_to_copy_now = total_bytes_to_copy - bytes_copied; |
41 | 41 |
42 scoped_refptr<net::IOBufferWithSize> buf( | 42 scoped_refptr<net::IOBufferWithSize> buf( |
43 new net::IOBufferWithSize(bytes_to_copy_now)); | 43 new net::IOBufferWithSize(bytes_to_copy_now)); |
44 int bytes_read = request_body_stream_->Read(buf, buf->size()); | 44 int bytes_read = request_body_stream_->ReadSync(buf, buf->size()); |
45 if (bytes_read == 0) // Reached the end of the stream. | 45 if (bytes_read == 0) // Reached the end of the stream. |
46 break; | 46 break; |
47 | 47 |
48 memcpy(write_pointer, buf->data(), bytes_read); | 48 memcpy(write_pointer, buf->data(), bytes_read); |
49 | 49 |
50 // Advance our copy tally | 50 // Advance our copy tally |
51 bytes_copied += bytes_read; | 51 bytes_copied += bytes_read; |
52 | 52 |
53 // Advance our write pointer | 53 // Advance our write pointer |
54 write_pointer += bytes_read; | 54 write_pointer += bytes_read; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 if (0 == (grf_stat_flag & STATFLAG_NONAME)) { | 92 if (0 == (grf_stat_flag & STATFLAG_NONAME)) { |
93 const wchar_t kStreamBuffer[] = L"PostStream"; | 93 const wchar_t kStreamBuffer[] = L"PostStream"; |
94 stat_stg->pwcsName = | 94 stat_stg->pwcsName = |
95 static_cast<wchar_t*>(::CoTaskMemAlloc(sizeof(kStreamBuffer))); | 95 static_cast<wchar_t*>(::CoTaskMemAlloc(sizeof(kStreamBuffer))); |
96 lstrcpy(stat_stg->pwcsName, kStreamBuffer); | 96 lstrcpy(stat_stg->pwcsName, kStreamBuffer); |
97 } | 97 } |
98 stat_stg->type = STGTY_STREAM; | 98 stat_stg->type = STGTY_STREAM; |
99 stat_stg->cbSize.QuadPart = request_body_stream_->size(); | 99 stat_stg->cbSize.QuadPart = request_body_stream_->size(); |
100 return S_OK; | 100 return S_OK; |
101 } | 101 } |
OLD | NEW |