| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/loader/WorkerLoaderClientBridge.h" | 32 #include "core/loader/WorkerLoaderClientBridge.h" |
| 33 | 33 |
| 34 #include "core/dom/CrossThreadTask.h" | 34 #include "core/dom/CrossThreadTask.h" |
| 35 #include "core/loader/ThreadableLoaderClientWrapper.h" | 35 #include "core/loader/ThreadableLoaderClientWrapper.h" |
| 36 #include "core/workers/WorkerGlobalScope.h" | 36 #include "core/workers/WorkerGlobalScope.h" |
| 37 #include "core/workers/WorkerLoaderProxy.h" | 37 #include "core/workers/WorkerLoaderProxy.h" |
| 38 #include "wtf/PassOwnPtr.h" | 38 #include "wtf/PassOwnPtr.h" |
| 39 #include "wtf/PassRefPtr.h" | 39 #include "wtf/PassRefPtr.h" |
| 40 #include <limits> |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 PassOwnPtr<ThreadableLoaderClient> WorkerLoaderClientBridge::create(PassRefPtr<T
hreadableLoaderClientWrapper> client, WorkerLoaderProxy& loaderProxy) | 44 PassOwnPtr<ThreadableLoaderClient> WorkerLoaderClientBridge::create(PassRefPtr<T
hreadableLoaderClientWrapper> client, WorkerLoaderProxy& loaderProxy) |
| 44 { | 45 { |
| 45 return adoptPtr(new WorkerLoaderClientBridge(client, loaderProxy)); | 46 return adoptPtr(new WorkerLoaderClientBridge(client, loaderProxy)); |
| 46 } | 47 } |
| 47 | 48 |
| 48 WorkerLoaderClientBridge::~WorkerLoaderClientBridge() | 49 WorkerLoaderClientBridge::~WorkerLoaderClientBridge() |
| 49 { | 50 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 68 } | 69 } |
| 69 | 70 |
| 70 void WorkerLoaderClientBridge::didReceiveResponse(unsigned long identifier, cons
t ResourceResponse& response) | 71 void WorkerLoaderClientBridge::didReceiveResponse(unsigned long identifier, cons
t ResourceResponse& response) |
| 71 { | 72 { |
| 72 m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGloba
lScopeDidReceiveResponse, m_workerClientWrapper, identifier, response)); | 73 m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGloba
lScopeDidReceiveResponse, m_workerClientWrapper, identifier, response)); |
| 73 } | 74 } |
| 74 | 75 |
| 75 static void workerGlobalScopeDidReceiveData(ExecutionContext* context, PassRefPt
r<ThreadableLoaderClientWrapper> workerClientWrapper, PassOwnPtr<Vector<char> >
vectorData) | 76 static void workerGlobalScopeDidReceiveData(ExecutionContext* context, PassRefPt
r<ThreadableLoaderClientWrapper> workerClientWrapper, PassOwnPtr<Vector<char> >
vectorData) |
| 76 { | 77 { |
| 77 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); | 78 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); |
| 79 RELEASE_ASSERT(vectorData->size() <= std::numeric_limits<unsigned>::max()); |
| 78 workerClientWrapper->didReceiveData(vectorData->data(), vectorData->size()); | 80 workerClientWrapper->didReceiveData(vectorData->data(), vectorData->size()); |
| 79 } | 81 } |
| 80 | 82 |
| 81 void WorkerLoaderClientBridge::didReceiveData(const char* data, int dataLength) | 83 void WorkerLoaderClientBridge::didReceiveData(const char* data, unsigned dataLen
gth) |
| 82 { | 84 { |
| 83 OwnPtr<Vector<char> > vector = adoptPtr(new Vector<char>(dataLength)); // ne
eds to be an OwnPtr for usage with createCrossThreadTask. | 85 OwnPtr<Vector<char> > vector = adoptPtr(new Vector<char>(dataLength)); // ne
eds to be an OwnPtr for usage with createCrossThreadTask. |
| 84 memcpy(vector->data(), data, dataLength); | 86 memcpy(vector->data(), data, dataLength); |
| 85 m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGloba
lScopeDidReceiveData, m_workerClientWrapper, vector.release())); | 87 m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGloba
lScopeDidReceiveData, m_workerClientWrapper, vector.release())); |
| 86 } | 88 } |
| 87 | 89 |
| 88 static void workerGlobalScopeDidDownloadData(ExecutionContext* context, PassRefP
tr<ThreadableLoaderClientWrapper> workerClientWrapper, int dataLength) | 90 static void workerGlobalScopeDidDownloadData(ExecutionContext* context, PassRefP
tr<ThreadableLoaderClientWrapper> workerClientWrapper, int dataLength) |
| 89 { | 91 { |
| 90 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); | 92 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); |
| 91 workerClientWrapper->didDownloadData(dataLength); | 93 workerClientWrapper->didDownloadData(dataLength); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGloba
lScopeDidFailRedirectCheck, m_workerClientWrapper)); | 155 m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGloba
lScopeDidFailRedirectCheck, m_workerClientWrapper)); |
| 154 } | 156 } |
| 155 | 157 |
| 156 WorkerLoaderClientBridge::WorkerLoaderClientBridge(PassRefPtr<ThreadableLoaderCl
ientWrapper> clientWrapper, WorkerLoaderProxy& loaderProxy) | 158 WorkerLoaderClientBridge::WorkerLoaderClientBridge(PassRefPtr<ThreadableLoaderCl
ientWrapper> clientWrapper, WorkerLoaderProxy& loaderProxy) |
| 157 : m_workerClientWrapper(clientWrapper) | 159 : m_workerClientWrapper(clientWrapper) |
| 158 , m_loaderProxy(loaderProxy) | 160 , m_loaderProxy(loaderProxy) |
| 159 { | 161 { |
| 160 } | 162 } |
| 161 | 163 |
| 162 } // namespace blink | 164 } // namespace blink |
| OLD | NEW |