OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_bind_status_callback.h" | 5 #include "chrome_frame/urlmon_bind_status_callback.h" |
6 | 6 |
7 #include <mshtml.h> | 7 #include <mshtml.h> |
8 #include <shlguid.h> | 8 #include <shlguid.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/threading/platform_thread.h" |
13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
14 #include "chrome_frame/bind_context_info.h" | 15 #include "chrome_frame/bind_context_info.h" |
15 #include "chrome_frame/exception_barrier.h" | 16 #include "chrome_frame/exception_barrier.h" |
16 #include "chrome_frame/urlmon_moniker.h" | 17 #include "chrome_frame/urlmon_moniker.h" |
17 #include "chrome_tab.h" // NOLINT | 18 #include "chrome_tab.h" // NOLINT |
18 | 19 |
19 | 20 |
20 // A helper to given feed data to the specified |bscb| using | 21 // A helper to given feed data to the specified |bscb| using |
21 // CacheStream instance. | 22 // CacheStream instance. |
22 HRESULT CacheStream::BSCBFeedData(IBindStatusCallback* bscb, const char* data, | 23 HRESULT CacheStream::BSCBFeedData(IBindStatusCallback* bscb, const char* data, |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 BSCBStorageBind::BSCBStorageBind() : clip_format_(CF_NULL) { | 207 BSCBStorageBind::BSCBStorageBind() : clip_format_(CF_NULL) { |
207 } | 208 } |
208 | 209 |
209 BSCBStorageBind::~BSCBStorageBind() { | 210 BSCBStorageBind::~BSCBStorageBind() { |
210 std::for_each(saved_progress_.begin(), saved_progress_.end(), | 211 std::for_each(saved_progress_.begin(), saved_progress_.end(), |
211 utils::DeleteObject()); | 212 utils::DeleteObject()); |
212 } | 213 } |
213 | 214 |
214 HRESULT BSCBStorageBind::Initialize(IMoniker* moniker, IBindCtx* bind_ctx) { | 215 HRESULT BSCBStorageBind::Initialize(IMoniker* moniker, IBindCtx* bind_ctx) { |
215 DVLOG(1) << __FUNCTION__ << me() | 216 DVLOG(1) << __FUNCTION__ << me() |
216 << base::StringPrintf(" tid=%i", PlatformThread::CurrentId()); | 217 << base::StringPrintf(" tid=%i", base::PlatformThread::CurrentId()); |
217 | 218 |
218 std::wstring url = GetActualUrlFromMoniker(moniker, bind_ctx, | 219 std::wstring url = GetActualUrlFromMoniker(moniker, bind_ctx, |
219 std::wstring()); | 220 std::wstring()); |
220 HRESULT hr = data_sniffer_.InitializeCache(url); | 221 HRESULT hr = data_sniffer_.InitializeCache(url); |
221 if (FAILED(hr)) | 222 if (FAILED(hr)) |
222 return hr; | 223 return hr; |
223 | 224 |
224 hr = AttachToBind(bind_ctx); | 225 hr = AttachToBind(bind_ctx); |
225 if (FAILED(hr)) { | 226 if (FAILED(hr)) { |
226 NOTREACHED() << __FUNCTION__ << me() << "AttachToBind error: " << hr; | 227 NOTREACHED() << __FUNCTION__ << me() << "AttachToBind error: " << hr; |
227 return hr; | 228 return hr; |
228 } | 229 } |
229 | 230 |
230 if (!delegate()) { | 231 if (!delegate()) { |
231 NOTREACHED() << __FUNCTION__ << me() << "No existing callback: " << hr; | 232 NOTREACHED() << __FUNCTION__ << me() << "No existing callback: " << hr; |
232 return E_FAIL; | 233 return E_FAIL; |
233 } | 234 } |
234 | 235 |
235 return hr; | 236 return hr; |
236 } | 237 } |
237 | 238 |
238 STDMETHODIMP BSCBStorageBind::OnProgress(ULONG progress, ULONG progress_max, | 239 STDMETHODIMP BSCBStorageBind::OnProgress(ULONG progress, ULONG progress_max, |
239 ULONG status_code, LPCWSTR status_text) { | 240 ULONG status_code, LPCWSTR status_text) { |
240 DVLOG(1) << __FUNCTION__ << me() | 241 DVLOG(1) << __FUNCTION__ << me() |
241 << base::StringPrintf(" status=%i tid=%i %ls", status_code, | 242 << base::StringPrintf(" status=%i tid=%i %ls", status_code, |
242 PlatformThread::CurrentId(), status_text); | 243 base::PlatformThread::CurrentId(), |
| 244 status_text); |
243 // Report all crashes in the exception handler if we wrap the callback. | 245 // Report all crashes in the exception handler if we wrap the callback. |
244 // Note that this avoids having the VEH report a crash if an SEH earlier in | 246 // Note that this avoids having the VEH report a crash if an SEH earlier in |
245 // the chain handles the exception. | 247 // the chain handles the exception. |
246 ExceptionBarrier barrier; | 248 ExceptionBarrier barrier; |
247 | 249 |
248 HRESULT hr = S_OK; | 250 HRESULT hr = S_OK; |
249 | 251 |
250 // Remember the last redirected URL in case we get switched into | 252 // Remember the last redirected URL in case we get switched into |
251 // chrome frame | 253 // chrome frame |
252 if (status_code == BINDSTATUS_REDIRECTING) { | 254 if (status_code == BINDSTATUS_REDIRECTING) { |
(...skipping 13 matching lines...) Expand all Loading... |
266 } | 268 } |
267 | 269 |
268 return hr; | 270 return hr; |
269 } | 271 } |
270 | 272 |
271 // Refer to urlmon_moniker.h for explanation of how things work. | 273 // Refer to urlmon_moniker.h for explanation of how things work. |
272 STDMETHODIMP BSCBStorageBind::OnDataAvailable(DWORD flags, DWORD size, | 274 STDMETHODIMP BSCBStorageBind::OnDataAvailable(DWORD flags, DWORD size, |
273 FORMATETC* format_etc, | 275 FORMATETC* format_etc, |
274 STGMEDIUM* stgmed) { | 276 STGMEDIUM* stgmed) { |
275 DVLOG(1) << __FUNCTION__ | 277 DVLOG(1) << __FUNCTION__ |
276 << base::StringPrintf(" tid=%i", PlatformThread::CurrentId()); | 278 << base::StringPrintf(" tid=%i", base::PlatformThread::CurrentId()); |
277 // Report all crashes in the exception handler if we wrap the callback. | 279 // Report all crashes in the exception handler if we wrap the callback. |
278 // Note that this avoids having the VEH report a crash if an SEH earlier in | 280 // Note that this avoids having the VEH report a crash if an SEH earlier in |
279 // the chain handles the exception. | 281 // the chain handles the exception. |
280 ExceptionBarrier barrier; | 282 ExceptionBarrier barrier; |
281 // Do not touch anything other than text/html. | 283 // Do not touch anything other than text/html. |
282 bool is_interesting = (format_etc && stgmed && stgmed->pstm && | 284 bool is_interesting = (format_etc && stgmed && stgmed->pstm && |
283 stgmed->tymed == TYMED_ISTREAM && | 285 stgmed->tymed == TYMED_ISTREAM && |
284 IsTextHtmlClipFormat(format_etc->cfFormat)); | 286 IsTextHtmlClipFormat(format_etc->cfFormat)); |
285 | 287 |
286 if (!is_interesting) { | 288 if (!is_interesting) { |
(...skipping 22 matching lines...) Expand all Loading... |
309 hr = MayPlayBack(flags); | 311 hr = MayPlayBack(flags); |
310 DCHECK(!data_sniffer_.is_cache_valid()); | 312 DCHECK(!data_sniffer_.is_cache_valid()); |
311 } else { | 313 } else { |
312 hr = CallbackImpl::OnDataAvailable(flags, size, format_etc, stgmed); | 314 hr = CallbackImpl::OnDataAvailable(flags, size, format_etc, stgmed); |
313 } | 315 } |
314 return hr; | 316 return hr; |
315 } | 317 } |
316 | 318 |
317 STDMETHODIMP BSCBStorageBind::OnStopBinding(HRESULT hresult, LPCWSTR error) { | 319 STDMETHODIMP BSCBStorageBind::OnStopBinding(HRESULT hresult, LPCWSTR error) { |
318 DVLOG(1) << __FUNCTION__ | 320 DVLOG(1) << __FUNCTION__ |
319 << base::StringPrintf(" tid=%i", PlatformThread::CurrentId()); | 321 << base::StringPrintf(" tid=%i", base::PlatformThread::CurrentId()); |
320 // Report all crashes in the exception handler if we wrap the callback. | 322 // Report all crashes in the exception handler if we wrap the callback. |
321 // Note that this avoids having the VEH report a crash if an SEH earlier in | 323 // Note that this avoids having the VEH report a crash if an SEH earlier in |
322 // the chain handles the exception. | 324 // the chain handles the exception. |
323 ExceptionBarrier barrier; | 325 ExceptionBarrier barrier; |
324 | 326 |
325 HRESULT hr = MayPlayBack(BSCF_LASTDATANOTIFICATION); | 327 HRESULT hr = MayPlayBack(BSCF_LASTDATANOTIFICATION); |
326 hr = CallbackImpl::OnStopBinding(hresult, error); | 328 hr = CallbackImpl::OnStopBinding(hresult, error); |
327 ReleaseBind(); | 329 ReleaseBind(); |
328 return hr; | 330 return hr; |
329 } | 331 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 case BINDSTATUS_CACHEFILENAMEAVAILABLE: | 423 case BINDSTATUS_CACHEFILENAMEAVAILABLE: |
422 case BINDSTATUS_SERVER_MIMETYPEAVAILABLE: | 424 case BINDSTATUS_SERVER_MIMETYPEAVAILABLE: |
423 return true; | 425 return true; |
424 default: | 426 default: |
425 break; | 427 break; |
426 } | 428 } |
427 } | 429 } |
428 | 430 |
429 return false; | 431 return false; |
430 } | 432 } |
OLD | NEW |