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

Unified Diff: net/http/http_network_transaction.cc

Issue 10829188: Use net::UploadDataStream::Init() instead of InitSync() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_network_transaction.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_network_transaction.cc
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 5acbecba59cb161d7f560c752d78345bc84824e9..b545c82d51cf33fddbeb652f1e8820ccb7b4f165 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -534,6 +534,13 @@ int HttpNetworkTransaction::DoLoop(int result) {
case STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE:
rv = DoGenerateServerAuthTokenComplete(rv);
break;
+ case STATE_INIT_REQUEST_BODY:
+ DCHECK_EQ(OK, rv);
+ rv = DoInitRequestBody();
+ break;
+ case STATE_INIT_REQUEST_BODY_COMPLETE:
+ rv = DoInitRequestBodyComplete(rv);
+ break;
case STATE_BUILD_REQUEST:
DCHECK_EQ(OK, rv);
net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST);
@@ -689,7 +696,7 @@ int HttpNetworkTransaction::DoGenerateServerAuthToken() {
int HttpNetworkTransaction::DoGenerateServerAuthTokenComplete(int rv) {
DCHECK_NE(ERR_IO_PENDING, rv);
if (rv == OK)
- next_state_ = STATE_BUILD_REQUEST;
+ next_state_ = STATE_INIT_REQUEST_BODY;
return rv;
}
@@ -742,18 +749,29 @@ void HttpNetworkTransaction::BuildRequestHeaders(bool using_proxy) {
request_headers_.MergeFrom(request_->extra_headers);
}
-int HttpNetworkTransaction::DoBuildRequest() {
- next_state_ = STATE_BUILD_REQUEST_COMPLETE;
+int HttpNetworkTransaction::DoInitRequestBody() {
+ next_state_ = STATE_INIT_REQUEST_BODY_COMPLETE;
request_body_.reset(NULL);
+ int error_code = OK;
eroman 2012/08/08 19:06:01 nit: for consistency you may want to call this |r
hashimoto 2012/08/09 04:35:20 Done.
if (request_->upload_data) {
request_body_.reset(new UploadDataStream(request_->upload_data));
- const int error_code = request_body_->InitSync();
- if (error_code != OK) {
+ error_code = request_body_->Init(io_callback_);
+ if (error_code != OK && error_code != ERR_IO_PENDING)
request_body_.reset(NULL);
eroman 2012/08/08 19:06:01 You can remove this: it will already be reset by D
hashimoto 2012/08/09 04:35:20 Done.
- return error_code;
- }
}
+ return error_code;
+}
+int HttpNetworkTransaction::DoInitRequestBodyComplete(int result) {
+ if (result == OK)
+ next_state_ = STATE_BUILD_REQUEST;
+ else
+ request_body_.reset(NULL);
+ return result;
+}
+
+int HttpNetworkTransaction::DoBuildRequest() {
+ next_state_ = STATE_BUILD_REQUEST_COMPLETE;
headers_valid_ = false;
// This is constructed lazily (instead of within our Start method), so that
@@ -1394,6 +1412,8 @@ std::string HttpNetworkTransaction::DescribeState(State state) {
switch (state) {
STATE_CASE(STATE_CREATE_STREAM);
STATE_CASE(STATE_CREATE_STREAM_COMPLETE);
+ STATE_CASE(STATE_INIT_REQUEST_BODY);
+ STATE_CASE(STATE_INIT_REQUEST_BODY_COMPLETE);
STATE_CASE(STATE_BUILD_REQUEST);
STATE_CASE(STATE_BUILD_REQUEST_COMPLETE);
STATE_CASE(STATE_SEND_REQUEST);
« no previous file with comments | « net/http/http_network_transaction.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698