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 #include "net/base/upload_bytes_element_reader.h" | 9 #include "net/base/upload_bytes_element_reader.h" |
10 #include "net/base/upload_file_element_reader.h" | 10 #include "net/base/upload_file_element_reader.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 element_readers.push_back(reader); | 52 element_readers.push_back(reader); |
53 } | 53 } |
54 upload_data_stream = new net::UploadDataStream(element_readers.Pass(), | 54 upload_data_stream = new net::UploadDataStream(element_readers.Pass(), |
55 upload_data->identifier()); | 55 upload_data->identifier()); |
56 } | 56 } |
57 return upload_data_stream; | 57 return upload_data_stream; |
58 } | 58 } |
59 | 59 |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 void UrlmonUploadDataStream::Initialize(net::UploadData* upload_data) { | 62 bool UrlmonUploadDataStream::Initialize(net::UploadData* upload_data) { |
63 upload_data_ = upload_data; | 63 upload_data_ = upload_data; |
64 request_body_stream_.reset(CreateUploadDataStream(upload_data)); | 64 request_body_stream_.reset(CreateUploadDataStream(upload_data)); |
65 const int result = request_body_stream_->Init(net::CompletionCallback()); | 65 return request_body_stream_->Init(net::CompletionCallback()) == net::OK; |
66 DCHECK_EQ(net::OK, result); | |
67 } | 66 } |
68 | 67 |
69 STDMETHODIMP UrlmonUploadDataStream::Read(void* pv, ULONG cb, ULONG* read) { | 68 STDMETHODIMP UrlmonUploadDataStream::Read(void* pv, ULONG cb, ULONG* read) { |
70 if (pv == NULL) { | 69 if (pv == NULL) { |
71 NOTREACHED(); | 70 NOTREACHED(); |
72 return E_POINTER; | 71 return E_POINTER; |
73 } | 72 } |
74 | 73 |
75 // Have we already read past the end of the stream? | 74 // Have we already read past the end of the stream? |
76 if (request_body_stream_->IsEOF()) { | 75 if (request_body_stream_->IsEOF()) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 if (0 == (grf_stat_flag & STATFLAG_NONAME)) { | 144 if (0 == (grf_stat_flag & STATFLAG_NONAME)) { |
146 const wchar_t kStreamBuffer[] = L"PostStream"; | 145 const wchar_t kStreamBuffer[] = L"PostStream"; |
147 stat_stg->pwcsName = | 146 stat_stg->pwcsName = |
148 static_cast<wchar_t*>(::CoTaskMemAlloc(sizeof(kStreamBuffer))); | 147 static_cast<wchar_t*>(::CoTaskMemAlloc(sizeof(kStreamBuffer))); |
149 lstrcpy(stat_stg->pwcsName, kStreamBuffer); | 148 lstrcpy(stat_stg->pwcsName, kStreamBuffer); |
150 } | 149 } |
151 stat_stg->type = STGTY_STREAM; | 150 stat_stg->type = STGTY_STREAM; |
152 stat_stg->cbSize.QuadPart = request_body_stream_->size(); | 151 stat_stg->cbSize.QuadPart = request_body_stream_->size(); |
153 return S_OK; | 152 return S_OK; |
154 } | 153 } |
OLD | NEW |