| 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 m_workerLoaderProxy->postTaskToLoader( | 273 m_workerLoaderProxy->postTaskToLoader( |
| 274 BLINK_FROM_HERE, | 274 BLINK_FROM_HERE, |
| 275 createCrossThreadTask(&MainThreadLoaderHolder::overrideTimeout, | 275 createCrossThreadTask(&MainThreadLoaderHolder::overrideTimeout, |
| 276 m_mainThreadLoaderHolder, timeoutMilliseconds)); | 276 m_mainThreadLoaderHolder, timeoutMilliseconds)); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void WorkerThreadableLoader::cancel() { | 279 void WorkerThreadableLoader::cancel() { |
| 280 DCHECK(!isMainThread()); | 280 DCHECK(!isMainThread()); |
| 281 if (m_mainThreadLoaderHolder) { | 281 if (m_mainThreadLoaderHolder) { |
| 282 m_workerLoaderProxy->postTaskToLoader( | 282 m_workerLoaderProxy->postTaskToLoader( |
| 283 BLINK_FROM_HERE, createCrossThreadTask(&MainThreadLoaderHolder::cancel, | 283 BLINK_FROM_HERE, |
| 284 m_mainThreadLoaderHolder)); | 284 createCrossThreadTask(&MainThreadLoaderHolder::cancel, |
| 285 m_mainThreadLoaderHolder)); |
| 285 m_mainThreadLoaderHolder = nullptr; | 286 m_mainThreadLoaderHolder = nullptr; |
| 286 } | 287 } |
| 287 | 288 |
| 288 if (!m_client) | 289 if (!m_client) |
| 289 return; | 290 return; |
| 290 | 291 |
| 291 // If the client hasn't reached a termination state, then transition it | 292 // If the client hasn't reached a termination state, then transition it |
| 292 // by sending a cancellation error. | 293 // by sending a cancellation error. |
| 293 // Note: no more client callbacks will be done after this method -- the | 294 // Note: no more client callbacks will be done after this method -- the |
| 294 // clearClient() call ensures that. | 295 // clearClient() call ensures that. |
| 295 ResourceError error(String(), 0, String(), String()); | 296 ResourceError error(String(), 0, String(), String()); |
| 296 error.setIsCancellation(true); | 297 error.setIsCancellation(true); |
| 297 didFail(error); | 298 didFail(error); |
| 298 DCHECK(!m_client); | 299 DCHECK(!m_client); |
| 299 } | 300 } |
| 300 | 301 |
| 301 void WorkerThreadableLoader::didStart( | 302 void WorkerThreadableLoader::didStart( |
| 302 MainThreadLoaderHolder* mainThreadLoaderHolder) { | 303 MainThreadLoaderHolder* mainThreadLoaderHolder) { |
| 303 DCHECK(!isMainThread()); | 304 DCHECK(!isMainThread()); |
| 304 DCHECK(!m_mainThreadLoaderHolder); | 305 DCHECK(!m_mainThreadLoaderHolder); |
| 305 DCHECK(mainThreadLoaderHolder); | 306 DCHECK(mainThreadLoaderHolder); |
| 306 if (!m_client) { | 307 if (!m_client) { |
| 307 // The thread is terminating. | 308 // The thread is terminating. |
| 308 m_workerLoaderProxy->postTaskToLoader( | 309 m_workerLoaderProxy->postTaskToLoader( |
| 309 BLINK_FROM_HERE, createCrossThreadTask(&MainThreadLoaderHolder::cancel, | 310 BLINK_FROM_HERE, |
| 310 wrapCrossThreadPersistent( | 311 createCrossThreadTask( |
| 311 mainThreadLoaderHolder))); | 312 &MainThreadLoaderHolder::cancel, |
| 313 wrapCrossThreadPersistent(mainThreadLoaderHolder))); |
| 312 return; | 314 return; |
| 313 } | 315 } |
| 314 | 316 |
| 315 m_mainThreadLoaderHolder = mainThreadLoaderHolder; | 317 m_mainThreadLoaderHolder = mainThreadLoaderHolder; |
| 316 } | 318 } |
| 317 | 319 |
| 318 void WorkerThreadableLoader::didSendData( | 320 void WorkerThreadableLoader::didSendData( |
| 319 unsigned long long bytesSent, | 321 unsigned long long bytesSent, |
| 320 unsigned long long totalBytesToBeSent) { | 322 unsigned long long totalBytesToBeSent) { |
| 321 DCHECK(!isMainThread()); | 323 DCHECK(!isMainThread()); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 } | 543 } |
| 542 | 544 |
| 543 void WorkerThreadableLoader::MainThreadLoaderHolder::didDownloadData( | 545 void WorkerThreadableLoader::MainThreadLoaderHolder::didDownloadData( |
| 544 int dataLength) { | 546 int dataLength) { |
| 545 DCHECK(isMainThread()); | 547 DCHECK(isMainThread()); |
| 546 CrossThreadPersistent<WorkerThreadableLoader> workerLoader = | 548 CrossThreadPersistent<WorkerThreadableLoader> workerLoader = |
| 547 m_workerLoader.get(); | 549 m_workerLoader.get(); |
| 548 if (!workerLoader || !m_forwarder) | 550 if (!workerLoader || !m_forwarder) |
| 549 return; | 551 return; |
| 550 m_forwarder->forwardTask( | 552 m_forwarder->forwardTask( |
| 551 BLINK_FROM_HERE, crossThreadBind(&WorkerThreadableLoader::didDownloadData, | 553 BLINK_FROM_HERE, |
| 552 workerLoader, dataLength)); | 554 crossThreadBind(&WorkerThreadableLoader::didDownloadData, workerLoader, |
| 555 dataLength)); |
| 553 } | 556 } |
| 554 | 557 |
| 555 void WorkerThreadableLoader::MainThreadLoaderHolder::didReceiveCachedMetadata( | 558 void WorkerThreadableLoader::MainThreadLoaderHolder::didReceiveCachedMetadata( |
| 556 const char* data, | 559 const char* data, |
| 557 int dataLength) { | 560 int dataLength) { |
| 558 DCHECK(isMainThread()); | 561 DCHECK(isMainThread()); |
| 559 CrossThreadPersistent<WorkerThreadableLoader> workerLoader = | 562 CrossThreadPersistent<WorkerThreadableLoader> workerLoader = |
| 560 m_workerLoader.get(); | 563 m_workerLoader.get(); |
| 561 if (!workerLoader || !m_forwarder) | 564 if (!workerLoader || !m_forwarder) |
| 562 return; | 565 return; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 const ResourceLoaderOptions& originalResourceLoaderOptions) { | 668 const ResourceLoaderOptions& originalResourceLoaderOptions) { |
| 666 DCHECK(isMainThread()); | 669 DCHECK(isMainThread()); |
| 667 ResourceLoaderOptions resourceLoaderOptions = originalResourceLoaderOptions; | 670 ResourceLoaderOptions resourceLoaderOptions = originalResourceLoaderOptions; |
| 668 resourceLoaderOptions.requestInitiatorContext = WorkerContext; | 671 resourceLoaderOptions.requestInitiatorContext = WorkerContext; |
| 669 m_mainThreadLoader = DocumentThreadableLoader::create(document, this, options, | 672 m_mainThreadLoader = DocumentThreadableLoader::create(document, this, options, |
| 670 resourceLoaderOptions); | 673 resourceLoaderOptions); |
| 671 m_mainThreadLoader->start(ResourceRequest(request.get())); | 674 m_mainThreadLoader->start(ResourceRequest(request.get())); |
| 672 } | 675 } |
| 673 | 676 |
| 674 } // namespace blink | 677 } // namespace blink |
| OLD | NEW |