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

Side by Side Diff: chrome_frame/urlmon_url_request.cc

Issue 6166010: net: Remove typedef net::URLRequestStatus URLRequestStatus; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 | « chrome_frame/test/url_request_test.cc ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_url_request.h" 5 #include "chrome_frame/urlmon_url_request.h"
6 6
7 #include <wininet.h> 7 #include <wininet.h>
8 #include <urlmon.h> 8 #include <urlmon.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 DCHECK(thread_ == 0 || thread_ == base::PlatformThread::CurrentId()); 51 DCHECK(thread_ == 0 || thread_ == base::PlatformThread::CurrentId());
52 thread_ = base::PlatformThread::CurrentId(); 52 thread_ = base::PlatformThread::CurrentId();
53 status_.Start(); 53 status_.Start();
54 // The UrlmonUrlRequest instance can get destroyed in the context of 54 // The UrlmonUrlRequest instance can get destroyed in the context of
55 // StartAsyncDownload if BindToStorage finishes synchronously with an error. 55 // StartAsyncDownload if BindToStorage finishes synchronously with an error.
56 // Grab a reference to protect against this. 56 // Grab a reference to protect against this.
57 scoped_refptr<UrlmonUrlRequest> ref(this); 57 scoped_refptr<UrlmonUrlRequest> ref(this);
58 HRESULT hr = StartAsyncDownload(); 58 HRESULT hr = StartAsyncDownload();
59 if (FAILED(hr) && status_.get_state() != UrlmonUrlRequest::Status::DONE) { 59 if (FAILED(hr) && status_.get_state() != UrlmonUrlRequest::Status::DONE) {
60 status_.Done(); 60 status_.Done();
61 status_.set_result(URLRequestStatus::FAILED, HresultToNetError(hr)); 61 status_.set_result(net::URLRequestStatus::FAILED, HresultToNetError(hr));
62 NotifyDelegateAndDie(); 62 NotifyDelegateAndDie();
63 } 63 }
64 return true; 64 return true;
65 } 65 }
66 66
67 void UrlmonUrlRequest::Stop() { 67 void UrlmonUrlRequest::Stop() {
68 DCHECK_EQ(thread_, base::PlatformThread::CurrentId()); 68 DCHECK_EQ(thread_, base::PlatformThread::CurrentId());
69 DCHECK((status_.get_state() != Status::DONE) == (binding_ != NULL)); 69 DCHECK((status_.get_state() != Status::DONE) == (binding_ != NULL));
70 Status::State state = status_.get_state(); 70 Status::State state = status_.get_state();
71 delegate_ = NULL; 71 delegate_ = NULL;
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 if (state == Status::WORKING) { 366 if (state == Status::WORKING) {
367 status_.set_result(result); 367 status_.set_result(result);
368 368
369 // Special case. If the last request was a redirect and the current OS 369 // Special case. If the last request was a redirect and the current OS
370 // error value is E_ACCESSDENIED, that means an unsafe redirect was 370 // error value is E_ACCESSDENIED, that means an unsafe redirect was
371 // attempted. In that case, correct the OS error value to be the more 371 // attempted. In that case, correct the OS error value to be the more
372 // specific ERR_UNSAFE_REDIRECT error value. 372 // specific ERR_UNSAFE_REDIRECT error value.
373 if (result == E_ACCESSDENIED) { 373 if (result == E_ACCESSDENIED) {
374 int http_code = GetHttpResponseStatusFromBinding(binding_); 374 int http_code = GetHttpResponseStatusFromBinding(binding_);
375 if (300 <= http_code && http_code < 400) { 375 if (300 <= http_code && http_code < 400) {
376 status_.set_result(URLRequestStatus::FAILED, 376 status_.set_result(net::URLRequestStatus::FAILED,
377 net::ERR_UNSAFE_REDIRECT); 377 net::ERR_UNSAFE_REDIRECT);
378 } 378 }
379 } 379 }
380 380
381 // The code below seems easy but it is not. :) 381 // The code below seems easy but it is not. :)
382 // The network policy in Chrome network is that error code/end_of_stream 382 // The network policy in Chrome network is that error code/end_of_stream
383 // should be returned only as a result of read (or start) request. 383 // should be returned only as a result of read (or start) request.
384 // Here are the possible cases: 384 // Here are the possible cases:
385 // pending_data_|pending_read 385 // pending_data_|pending_read
386 // FALSE |FALSE => EndRequest if no headers, otherwise wait for Read. 386 // FALSE |FALSE => EndRequest if no headers, otherwise wait for Read.
387 // FALSE |TRUE => EndRequest. 387 // FALSE |TRUE => EndRequest.
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 831
832 void UrlmonUrlRequest::NotifyDelegateAndDie() { 832 void UrlmonUrlRequest::NotifyDelegateAndDie() {
833 DCHECK_EQ(thread_, base::PlatformThread::CurrentId()); 833 DCHECK_EQ(thread_, base::PlatformThread::CurrentId());
834 DVLOG(1) << __FUNCTION__ << me(); 834 DVLOG(1) << __FUNCTION__ << me();
835 835
836 PluginUrlRequestDelegate* delegate = delegate_; 836 PluginUrlRequestDelegate* delegate = delegate_;
837 delegate_ = NULL; 837 delegate_ = NULL;
838 ReleaseBindings(); 838 ReleaseBindings();
839 TerminateTransaction(); 839 TerminateTransaction();
840 if (delegate) { 840 if (delegate) {
841 URLRequestStatus result = status_.get_result(); 841 net::URLRequestStatus result = status_.get_result();
842 delegate->OnResponseEnd(id(), result); 842 delegate->OnResponseEnd(id(), result);
843 } else { 843 } else {
844 DLOG(WARNING) << __FUNCTION__ << me() << "no delegate"; 844 DLOG(WARNING) << __FUNCTION__ << me() << "no delegate";
845 } 845 }
846 } 846 }
847 847
848 void UrlmonUrlRequest::TerminateTransaction() { 848 void UrlmonUrlRequest::TerminateTransaction() {
849 if (cleanup_transaction_ && bind_context_ && moniker_) { 849 if (cleanup_transaction_ && bind_context_ && moniker_) {
850 // We return INET_E_TERMINATED_BIND from our OnDataAvailable implementation 850 // We return INET_E_TERMINATED_BIND from our OnDataAvailable implementation
851 // to ensure that the transaction stays around if Chrome decides to issue 851 // to ensure that the transaction stays around if Chrome decides to issue
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 scoped_refptr<UrlmonUrlRequest> new_request; 980 scoped_refptr<UrlmonUrlRequest> new_request;
981 bool is_started = false; 981 bool is_started = false;
982 if (pending_request_) { 982 if (pending_request_) {
983 if (pending_request_->url() != request_info.url) { 983 if (pending_request_->url() != request_info.url) {
984 DLOG(WARNING) << __FUNCTION__ 984 DLOG(WARNING) << __FUNCTION__
985 << "Received unexpected url request for url:" 985 << "Received unexpected url request for url:"
986 << request_info.url 986 << request_info.url
987 << ".Pending url request for url:" 987 << ".Pending url request for url:"
988 << pending_request_->url() 988 << pending_request_->url()
989 << " was expected."; 989 << " was expected.";
990 URLRequestStatus result; 990 net::URLRequestStatus result;
991 result.set_status(URLRequestStatus::FAILED); 991 result.set_status(net::URLRequestStatus::FAILED);
992 OnResponseEnd(request_id, result); 992 OnResponseEnd(request_id, result);
993 return; 993 return;
994 } 994 }
995 new_request.swap(pending_request_); 995 new_request.swap(pending_request_);
996 is_started = true; 996 is_started = true;
997 DVLOG(1) << __FUNCTION__ << new_request->me() 997 DVLOG(1) << __FUNCTION__ << new_request->me()
998 << " assigned id " << request_id; 998 << " assigned id " << request_id;
999 } else { 999 } else {
1000 CComObject<UrlmonUrlRequest>* created_request = NULL; 1000 CComObject<UrlmonUrlRequest>* created_request = NULL;
1001 CComObject<UrlmonUrlRequest>::CreateInstance(&created_request); 1001 CComObject<UrlmonUrlRequest>::CreateInstance(&created_request);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 const std::string& data) { 1168 const std::string& data) {
1169 DCHECK_NE(request_id, -1); 1169 DCHECK_NE(request_id, -1);
1170 DVLOG(1) << __FUNCTION__ << " id: " << request_id; 1170 DVLOG(1) << __FUNCTION__ << " id: " << request_id;
1171 DCHECK(LookupRequest(request_id) != NULL); 1171 DCHECK(LookupRequest(request_id) != NULL);
1172 ++calling_delegate_; 1172 ++calling_delegate_;
1173 delegate_->OnReadComplete(request_id, data); 1173 delegate_->OnReadComplete(request_id, data);
1174 --calling_delegate_; 1174 --calling_delegate_;
1175 DVLOG(1) << __FUNCTION__ << " done id: " << request_id; 1175 DVLOG(1) << __FUNCTION__ << " done id: " << request_id;
1176 } 1176 }
1177 1177
1178 void UrlmonUrlRequestManager::OnResponseEnd(int request_id, 1178 void UrlmonUrlRequestManager::OnResponseEnd(
1179 const URLRequestStatus& status) { 1179 int request_id,
1180 const net::URLRequestStatus& status) {
1180 DCHECK_NE(request_id, -1); 1181 DCHECK_NE(request_id, -1);
1181 DVLOG(1) << __FUNCTION__; 1182 DVLOG(1) << __FUNCTION__;
1182 DCHECK(status.status() != URLRequestStatus::CANCELED); 1183 DCHECK(status.status() != net::URLRequestStatus::CANCELED);
1183 RequestMap::size_type n = request_map_.erase(request_id); 1184 RequestMap::size_type n = request_map_.erase(request_id);
1184 if (n != 1u) { 1185 if (n != 1u) {
1185 DLOG(WARNING) << __FUNCTION__ 1186 DLOG(WARNING) << __FUNCTION__
1186 << " Failed to find request id:" 1187 << " Failed to find request id:"
1187 << request_id; 1188 << request_id;
1188 } 1189 }
1189 ++calling_delegate_; 1190 ++calling_delegate_;
1190 delegate_->OnResponseEnd(request_id, status); 1191 delegate_->OnResponseEnd(request_id, status);
1191 --calling_delegate_; 1192 --calling_delegate_;
1192 } 1193 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 privacy_info_.privacy_records[UTF8ToWide(url)]; 1239 privacy_info_.privacy_records[UTF8ToWide(url)];
1239 1240
1240 privacy_entry.flags |= flags; 1241 privacy_entry.flags |= flags;
1241 privacy_entry.policy_ref = UTF8ToWide(policy_ref); 1242 privacy_entry.policy_ref = UTF8ToWide(policy_ref);
1242 1243
1243 if (fire_privacy_event && IsWindow(notification_window_)) { 1244 if (fire_privacy_event && IsWindow(notification_window_)) {
1244 PostMessage(notification_window_, WM_FIRE_PRIVACY_CHANGE_NOTIFICATION, 1, 1245 PostMessage(notification_window_, WM_FIRE_PRIVACY_CHANGE_NOTIFICATION, 1,
1245 0); 1246 0);
1246 } 1247 }
1247 } 1248 }
OLDNEW
« no previous file with comments | « chrome_frame/test/url_request_test.cc ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698