OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "core/loader/DocumentThreadableLoader.h" | 35 #include "core/loader/DocumentThreadableLoader.h" |
36 #include "core/timing/WorkerGlobalScopePerformance.h" | 36 #include "core/timing/WorkerGlobalScopePerformance.h" |
37 #include "core/workers/WorkerGlobalScope.h" | 37 #include "core/workers/WorkerGlobalScope.h" |
38 #include "core/workers/WorkerLoaderProxy.h" | 38 #include "core/workers/WorkerLoaderProxy.h" |
39 #include "platform/CrossThreadFunctional.h" | 39 #include "platform/CrossThreadFunctional.h" |
40 #include "platform/heap/SafePoint.h" | 40 #include "platform/heap/SafePoint.h" |
41 #include "platform/network/ResourceError.h" | 41 #include "platform/network/ResourceError.h" |
42 #include "platform/network/ResourceRequest.h" | 42 #include "platform/network/ResourceRequest.h" |
43 #include "platform/network/ResourceResponse.h" | 43 #include "platform/network/ResourceResponse.h" |
44 #include "platform/network/ResourceTimingInfo.h" | 44 #include "platform/network/ResourceTimingInfo.h" |
| 45 #include "platform/weborigin/KURL.h" |
45 #include "platform/weborigin/SecurityPolicy.h" | 46 #include "platform/weborigin/SecurityPolicy.h" |
46 #include "wtf/debug/Alias.h" | 47 #include "wtf/debug/Alias.h" |
47 #include <memory> | 48 #include <memory> |
48 | 49 |
49 namespace blink { | 50 namespace blink { |
50 | 51 |
51 namespace { | 52 namespace { |
52 | 53 |
53 std::unique_ptr<Vector<char>> createVectorFromMemoryRegion( | 54 std::unique_ptr<Vector<char>> createVectorFromMemoryRegion( |
54 const char* data, | 55 const char* data, |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 317 |
317 void WorkerThreadableLoader::didSendData( | 318 void WorkerThreadableLoader::didSendData( |
318 unsigned long long bytesSent, | 319 unsigned long long bytesSent, |
319 unsigned long long totalBytesToBeSent) { | 320 unsigned long long totalBytesToBeSent) { |
320 DCHECK(!isMainThread()); | 321 DCHECK(!isMainThread()); |
321 if (!m_client) | 322 if (!m_client) |
322 return; | 323 return; |
323 m_client->didSendData(bytesSent, totalBytesToBeSent); | 324 m_client->didSendData(bytesSent, totalBytesToBeSent); |
324 } | 325 } |
325 | 326 |
| 327 void WorkerThreadableLoader::didReceiveRedirectTo(const KURL& url) { |
| 328 DCHECK(!isMainThread()); |
| 329 if (!m_client) |
| 330 return; |
| 331 m_client->didReceiveRedirectTo(url); |
| 332 } |
| 333 |
326 void WorkerThreadableLoader::didReceiveResponse( | 334 void WorkerThreadableLoader::didReceiveResponse( |
327 unsigned long identifier, | 335 unsigned long identifier, |
328 std::unique_ptr<CrossThreadResourceResponseData> responseData, | 336 std::unique_ptr<CrossThreadResourceResponseData> responseData, |
329 std::unique_ptr<WebDataConsumerHandle> handle) { | 337 std::unique_ptr<WebDataConsumerHandle> handle) { |
330 DCHECK(!isMainThread()); | 338 DCHECK(!isMainThread()); |
331 if (!m_client) | 339 if (!m_client) |
332 return; | 340 return; |
333 ResourceResponse response(responseData.get()); | 341 ResourceResponse response(responseData.get()); |
334 m_client->didReceiveResponse(identifier, response, std::move(handle)); | 342 m_client->didReceiveResponse(identifier, response, std::move(handle)); |
335 } | 343 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 CrossThreadPersistent<WorkerThreadableLoader> workerLoader = | 490 CrossThreadPersistent<WorkerThreadableLoader> workerLoader = |
483 m_workerLoader.get(); | 491 m_workerLoader.get(); |
484 if (!workerLoader || !m_forwarder) | 492 if (!workerLoader || !m_forwarder) |
485 return; | 493 return; |
486 m_forwarder->forwardTask( | 494 m_forwarder->forwardTask( |
487 BLINK_FROM_HERE, | 495 BLINK_FROM_HERE, |
488 createCrossThreadTask(&WorkerThreadableLoader::didSendData, workerLoader, | 496 createCrossThreadTask(&WorkerThreadableLoader::didSendData, workerLoader, |
489 bytesSent, totalBytesToBeSent)); | 497 bytesSent, totalBytesToBeSent)); |
490 } | 498 } |
491 | 499 |
| 500 void WorkerThreadableLoader::MainThreadLoaderHolder::didReceiveRedirectTo( |
| 501 const KURL& url) { |
| 502 DCHECK(isMainThread()); |
| 503 CrossThreadPersistent<WorkerThreadableLoader> workerLoader = |
| 504 m_workerLoader.get(); |
| 505 if (!workerLoader || !m_forwarder) |
| 506 return; |
| 507 m_forwarder->forwardTask( |
| 508 BLINK_FROM_HERE, |
| 509 createCrossThreadTask(&WorkerThreadableLoader::didReceiveRedirectTo, |
| 510 workerLoader, url)); |
| 511 } |
| 512 |
492 void WorkerThreadableLoader::MainThreadLoaderHolder::didReceiveResponse( | 513 void WorkerThreadableLoader::MainThreadLoaderHolder::didReceiveResponse( |
493 unsigned long identifier, | 514 unsigned long identifier, |
494 const ResourceResponse& response, | 515 const ResourceResponse& response, |
495 std::unique_ptr<WebDataConsumerHandle> handle) { | 516 std::unique_ptr<WebDataConsumerHandle> handle) { |
496 DCHECK(isMainThread()); | 517 DCHECK(isMainThread()); |
497 CrossThreadPersistent<WorkerThreadableLoader> workerLoader = | 518 CrossThreadPersistent<WorkerThreadableLoader> workerLoader = |
498 m_workerLoader.get(); | 519 m_workerLoader.get(); |
499 if (!workerLoader || !m_forwarder) | 520 if (!workerLoader || !m_forwarder) |
500 return; | 521 return; |
501 m_forwarder->forwardTask( | 522 m_forwarder->forwardTask( |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 const ResourceLoaderOptions& originalResourceLoaderOptions) { | 666 const ResourceLoaderOptions& originalResourceLoaderOptions) { |
646 DCHECK(isMainThread()); | 667 DCHECK(isMainThread()); |
647 ResourceLoaderOptions resourceLoaderOptions = originalResourceLoaderOptions; | 668 ResourceLoaderOptions resourceLoaderOptions = originalResourceLoaderOptions; |
648 resourceLoaderOptions.requestInitiatorContext = WorkerContext; | 669 resourceLoaderOptions.requestInitiatorContext = WorkerContext; |
649 m_mainThreadLoader = DocumentThreadableLoader::create(document, this, options, | 670 m_mainThreadLoader = DocumentThreadableLoader::create(document, this, options, |
650 resourceLoaderOptions); | 671 resourceLoaderOptions); |
651 m_mainThreadLoader->start(ResourceRequest(request.get())); | 672 m_mainThreadLoader->start(ResourceRequest(request.get())); |
652 } | 673 } |
653 | 674 |
654 } // namespace blink | 675 } // namespace blink |
OLD | NEW |