OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } | 139 } |
140 | 140 |
141 HRESULT UrlmonUrlRequest::SetRequestData(RequestData* data) { | 141 HRESULT UrlmonUrlRequest::SetRequestData(RequestData* data) { |
142 request_data_ = data; | 142 request_data_ = data; |
143 return S_OK; | 143 return S_OK; |
144 } | 144 } |
145 | 145 |
146 void UrlmonUrlRequest::StealMoniker(IMoniker** moniker) { | 146 void UrlmonUrlRequest::StealMoniker(IMoniker** moniker) { |
147 // Could be called in any thread. There should be no race | 147 // Could be called in any thread. There should be no race |
148 // since moniker_ is not released while we are in manager's request map. | 148 // since moniker_ is not released while we are in manager's request map. |
| 149 DLOG(INFO) << __FUNCTION__ << " id: " << id(); |
| 150 DLOG_IF(WARNING, moniker == NULL) << __FUNCTION__ << " no moniker"; |
149 *moniker = moniker_.Detach(); | 151 *moniker = moniker_.Detach(); |
150 } | 152 } |
151 | 153 |
152 STDMETHODIMP UrlmonUrlRequest::OnStartBinding(DWORD reserved, | 154 STDMETHODIMP UrlmonUrlRequest::OnStartBinding(DWORD reserved, |
153 IBinding *binding) { | 155 IBinding *binding) { |
154 DCHECK_EQ(thread_, PlatformThread::CurrentId()); | 156 DCHECK_EQ(thread_, PlatformThread::CurrentId()); |
155 binding_ = binding; | 157 binding_ = binding; |
156 return S_OK; | 158 return S_OK; |
157 } | 159 } |
158 | 160 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 bool upload_data = false; | 306 bool upload_data = false; |
305 | 307 |
306 if (LowerCaseEqualsASCII(method(), "get")) { | 308 if (LowerCaseEqualsASCII(method(), "get")) { |
307 bind_info->dwBindVerb = BINDVERB_GET; | 309 bind_info->dwBindVerb = BINDVERB_GET; |
308 } else if (LowerCaseEqualsASCII(method(), "post")) { | 310 } else if (LowerCaseEqualsASCII(method(), "post")) { |
309 bind_info->dwBindVerb = BINDVERB_POST; | 311 bind_info->dwBindVerb = BINDVERB_POST; |
310 upload_data = true; | 312 upload_data = true; |
311 } else if (LowerCaseEqualsASCII(method(), "put")) { | 313 } else if (LowerCaseEqualsASCII(method(), "put")) { |
312 bind_info->dwBindVerb = BINDVERB_PUT; | 314 bind_info->dwBindVerb = BINDVERB_PUT; |
313 upload_data = true; | 315 upload_data = true; |
| 316 } else if (LowerCaseEqualsASCII(method(), "head")) { |
| 317 std::wstring verb(ASCIIToWide(StringToUpperASCII(method()))); |
| 318 bind_info->dwBindVerb = BINDVERB_CUSTOM; |
| 319 bind_info->szCustomVerb = reinterpret_cast<wchar_t*>( |
| 320 ::CoTaskMemAlloc((verb.length() + 1) * sizeof(wchar_t))); |
| 321 lstrcpyW(bind_info->szCustomVerb, verb.c_str()); |
314 } else { | 322 } else { |
315 NOTREACHED() << "Unknown HTTP method."; | 323 NOTREACHED() << "Unknown HTTP method."; |
316 status_.set_result(URLRequestStatus::FAILED, net::ERR_METHOD_NOT_SUPPORTED); | 324 status_.set_result(URLRequestStatus::FAILED, net::ERR_METHOD_NOT_SUPPORTED); |
317 NotifyDelegateAndDie(); | 325 NotifyDelegateAndDie(); |
318 return E_FAIL; | 326 return E_FAIL; |
319 } | 327 } |
320 | 328 |
321 if (upload_data) { | 329 if (upload_data) { |
322 // Bypass caching proxies on POSTs and PUTs and avoid writing responses to | 330 // Bypass caching proxies on POSTs and PUTs and avoid writing responses to |
323 // these requests to the browser's cache | 331 // these requests to the browser's cache |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 new_request->SetRequestData(request_for_url->request_data()); | 915 new_request->SetRequestData(request_for_url->request_data()); |
908 } | 916 } |
909 | 917 |
910 DCHECK(LookupRequest(request_id).get() == NULL); | 918 DCHECK(LookupRequest(request_id).get() == NULL); |
911 request_map_[request_id] = new_request; | 919 request_map_[request_id] = new_request; |
912 map_empty_.Reset(); | 920 map_empty_.Reset(); |
913 new_request->Start(); | 921 new_request->Start(); |
914 } | 922 } |
915 | 923 |
916 void UrlmonUrlRequestManager::ReadRequest(int request_id, int bytes_to_read) { | 924 void UrlmonUrlRequestManager::ReadRequest(int request_id, int bytes_to_read) { |
917 DLOG(INFO) << __FUNCTION__; | 925 DLOG(INFO) << __FUNCTION__ << " id: " << request_id; |
918 ExecuteInWorkerThread(FROM_HERE, NewRunnableMethod(this, | 926 ExecuteInWorkerThread(FROM_HERE, NewRunnableMethod(this, |
919 &UrlmonUrlRequestManager::ReadRequestWorker, request_id, bytes_to_read)); | 927 &UrlmonUrlRequestManager::ReadRequestWorker, request_id, bytes_to_read)); |
920 } | 928 } |
921 | 929 |
922 void UrlmonUrlRequestManager::ReadRequestWorker(int request_id, | 930 void UrlmonUrlRequestManager::ReadRequestWorker(int request_id, |
923 int bytes_to_read) { | 931 int bytes_to_read) { |
924 DLOG(INFO) << __FUNCTION__; | 932 DLOG(INFO) << __FUNCTION__ << " id: " << request_id; |
925 DCHECK_EQ(worker_thread_.thread_id(), PlatformThread::CurrentId()); | 933 DCHECK_EQ(worker_thread_.thread_id(), PlatformThread::CurrentId()); |
926 scoped_refptr<UrlmonUrlRequest> request = LookupRequest(request_id); | 934 scoped_refptr<UrlmonUrlRequest> request = LookupRequest(request_id); |
927 // if zero, it may just have had network error. | 935 // if zero, it may just have had network error. |
928 if (request) { | 936 if (request) { |
929 request->Read(bytes_to_read); | 937 request->Read(bytes_to_read); |
930 } | 938 } |
931 } | 939 } |
932 | 940 |
933 void UrlmonUrlRequestManager::EndRequest(int request_id) { | 941 void UrlmonUrlRequestManager::EndRequest(int request_id) { |
934 DLOG(INFO) << __FUNCTION__; | 942 DLOG(INFO) << __FUNCTION__ << " id: " << request_id; |
935 ExecuteInWorkerThread(FROM_HERE, NewRunnableMethod(this, | 943 ExecuteInWorkerThread(FROM_HERE, NewRunnableMethod(this, |
936 &UrlmonUrlRequestManager::EndRequestWorker, request_id)); | 944 &UrlmonUrlRequestManager::EndRequestWorker, request_id)); |
937 } | 945 } |
938 | 946 |
939 void UrlmonUrlRequestManager::EndRequestWorker(int request_id) { | 947 void UrlmonUrlRequestManager::EndRequestWorker(int request_id) { |
940 DLOG(INFO) << __FUNCTION__; | 948 DLOG(INFO) << __FUNCTION__ << " id: " << request_id; |
941 DCHECK_EQ(worker_thread_.thread_id(), PlatformThread::CurrentId()); | 949 DCHECK_EQ(worker_thread_.thread_id(), PlatformThread::CurrentId()); |
942 scoped_refptr<UrlmonUrlRequest> request = LookupRequest(request_id); | 950 scoped_refptr<UrlmonUrlRequest> request = LookupRequest(request_id); |
943 if (request) { | 951 if (request) { |
944 request->Stop(); | 952 request->Stop(); |
945 } | 953 } |
946 } | 954 } |
947 | 955 |
948 void UrlmonUrlRequestManager::StopAll() { | 956 void UrlmonUrlRequestManager::StopAll() { |
949 DLOG(INFO) << __FUNCTION__; | 957 DLOG(INFO) << __FUNCTION__; |
950 do { | 958 do { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 done.Wait(); | 1071 done.Wait(); |
1064 } | 1072 } |
1065 | 1073 |
1066 void UrlmonUrlRequestManager::StealMonikerFromRequestWorker(int request_id, | 1074 void UrlmonUrlRequestManager::StealMonikerFromRequestWorker(int request_id, |
1067 IMoniker** moniker, base::WaitableEvent* done) { | 1075 IMoniker** moniker, base::WaitableEvent* done) { |
1068 if (!stopping_) { | 1076 if (!stopping_) { |
1069 scoped_refptr<UrlmonUrlRequest> request = LookupRequest(request_id); | 1077 scoped_refptr<UrlmonUrlRequest> request = LookupRequest(request_id); |
1070 if (request) { | 1078 if (request) { |
1071 request->StealMoniker(moniker); | 1079 request->StealMoniker(moniker); |
1072 request->Stop(); | 1080 request->Stop(); |
| 1081 } else { |
| 1082 DLOG(INFO) << __FUNCTION__ << " request not found."; |
1073 } | 1083 } |
| 1084 } else { |
| 1085 DLOG(INFO) << __FUNCTION__ << " request stopping."; |
1074 } | 1086 } |
1075 | 1087 |
1076 done->Signal(); | 1088 done->Signal(); |
1077 } | 1089 } |
1078 | 1090 |
1079 bool UrlmonUrlRequestManager::ExecuteInWorkerThread( | 1091 bool UrlmonUrlRequestManager::ExecuteInWorkerThread( |
1080 const tracked_objects::Location& from_here, Task* task) { | 1092 const tracked_objects::Location& from_here, Task* task) { |
1081 AutoLock lock(worker_thread_access_); | 1093 AutoLock lock(worker_thread_access_); |
1082 if (stopping_) { | 1094 if (stopping_) { |
1083 delete task; | 1095 delete task; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 privacy_entry.flags |= flags; | 1128 privacy_entry.flags |= flags; |
1117 privacy_entry.policy_ref = UTF8ToWide(policy_ref); | 1129 privacy_entry.policy_ref = UTF8ToWide(policy_ref); |
1118 } | 1130 } |
1119 | 1131 |
1120 if (fire_privacy_event && IsWindow(notification_window_)) { | 1132 if (fire_privacy_event && IsWindow(notification_window_)) { |
1121 PostMessage(notification_window_, WM_FIRE_PRIVACY_CHANGE_NOTIFICATION, 1, | 1133 PostMessage(notification_window_, WM_FIRE_PRIVACY_CHANGE_NOTIFICATION, 1, |
1122 0); | 1134 0); |
1123 } | 1135 } |
1124 } | 1136 } |
1125 | 1137 |
OLD | NEW |