Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Side by Side Diff: chrome_frame/urlmon_upload_data_stream.cc

Issue 9350060: net: Make UploadDataStream::Init() asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/upload_data_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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) {
11 upload_data_ = upload_data; 11 upload_data_ = upload_data;
12 request_body_stream_.reset( 12 request_body_stream_.reset(
13 new net::UploadDataStream(upload_data)); 13 new net::UploadDataStream(upload_data));
14 const int result = request_body_stream_->Init(); 14 const int result = request_body_stream_->InitSync();
15 DCHECK_EQ(net::OK, result); 15 DCHECK_EQ(net::OK, result);
16 } 16 }
17 17
18 STDMETHODIMP UrlmonUploadDataStream::Read(void* pv, ULONG cb, ULONG* read) { 18 STDMETHODIMP UrlmonUploadDataStream::Read(void* pv, ULONG cb, ULONG* read) {
19 if (pv == NULL) { 19 if (pv == NULL) {
20 NOTREACHED(); 20 NOTREACHED();
21 return E_POINTER; 21 return E_POINTER;
22 } 22 }
23 23
24 // Have we already read past the end of the stream? 24 // Have we already read past the end of the stream?
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return S_OK; 63 return S_OK;
64 } 64 }
65 65
66 STDMETHODIMP UrlmonUploadDataStream::Seek(LARGE_INTEGER move, DWORD origin, 66 STDMETHODIMP UrlmonUploadDataStream::Seek(LARGE_INTEGER move, DWORD origin,
67 ULARGE_INTEGER* new_pos) { 67 ULARGE_INTEGER* new_pos) {
68 // UploadDataStream is really not very seek-able, so for now allow 68 // UploadDataStream is really not very seek-able, so for now allow
69 // STREAM_SEEK_SETs to work with a 0 offset, but fail on everything else. 69 // STREAM_SEEK_SETs to work with a 0 offset, but fail on everything else.
70 if (origin == STREAM_SEEK_SET && move.QuadPart == 0) { 70 if (origin == STREAM_SEEK_SET && move.QuadPart == 0) {
71 if (request_body_stream_->position() != 0) { 71 if (request_body_stream_->position() != 0) {
72 request_body_stream_.reset(new net::UploadDataStream(upload_data_)); 72 request_body_stream_.reset(new net::UploadDataStream(upload_data_));
73 const int result = request_body_stream_->Init(); 73 const int result = request_body_stream_->InitSync();
74 DCHECK_EQ(net::OK, result); 74 DCHECK_EQ(net::OK, result);
75 } 75 }
76 if (new_pos) { 76 if (new_pos) {
77 new_pos->QuadPart = 0; 77 new_pos->QuadPart = 0;
78 } 78 }
79 return S_OK; 79 return S_OK;
80 } 80 }
81 81
82 DCHECK(false) << __FUNCTION__; 82 DCHECK(false) << __FUNCTION__;
83 return STG_E_INVALIDFUNCTION; 83 return STG_E_INVALIDFUNCTION;
84 } 84 }
85 85
86 STDMETHODIMP UrlmonUploadDataStream::Stat(STATSTG *stat_stg, 86 STDMETHODIMP UrlmonUploadDataStream::Stat(STATSTG *stat_stg,
87 DWORD grf_stat_flag) { 87 DWORD grf_stat_flag) {
88 if (stat_stg == NULL) 88 if (stat_stg == NULL)
89 return E_POINTER; 89 return E_POINTER;
90 90
91 memset(stat_stg, 0, sizeof(STATSTG)); 91 memset(stat_stg, 0, sizeof(STATSTG));
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 = upload_data_->GetContentLengthSync(); 99 stat_stg->cbSize.QuadPart = upload_data_->GetContentLengthSync();
100 return S_OK; 100 return S_OK;
101 } 101 }
OLDNEW
« no previous file with comments | « no previous file | net/base/upload_data_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698