OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 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 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "WorkerFileWriterCallbacksBridge.h" | 32 #include "WorkerFileWriterCallbacksBridge.h" |
33 | 33 |
34 #if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS) | 34 #if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS) |
35 | 35 |
36 #include "AsyncFileWriterClient.h" | 36 #include "AsyncFileWriterClient.h" |
| 37 #include "BlobData.h" |
37 #include "CrossThreadTask.h" | 38 #include "CrossThreadTask.h" |
38 #include "WebFileWriter.h" | 39 #include "WebFileWriter.h" |
39 #include "WebWorkerBase.h" | 40 #include "WebWorkerBase.h" |
40 #include "WorkerContext.h" | 41 #include "WorkerContext.h" |
41 #include "WorkerLoaderProxy.h" | 42 #include "WorkerLoaderProxy.h" |
42 #include "WorkerThread.h" | 43 #include "WorkerThread.h" |
43 #include <public/Platform.h> | 44 #include <public/Platform.h> |
44 #include <public/WebCString.h> | 45 #include <public/WebCString.h> |
45 #include <public/WebFileSystem.h> | 46 #include <public/WebFileSystem.h> |
46 #include <wtf/MainThread.h> | 47 #include <wtf/MainThread.h> |
47 #include <wtf/Threading.h> | 48 #include <wtf/Threading.h> |
48 | 49 |
49 using namespace WebCore; | 50 using namespace WebCore; |
50 | 51 |
51 namespace WebKit { | 52 namespace WebKit { |
52 | 53 |
53 void WorkerFileWriterCallbacksBridge::notifyStop() | 54 void WorkerFileWriterCallbacksBridge::notifyStop() |
54 { | 55 { |
55 ASSERT(m_workerContext->isContextThread()); | 56 ASSERT(m_workerContext->isContextThread()); |
56 m_clientOnWorkerThread = 0; | 57 m_clientOnWorkerThread = 0; |
57 } | 58 } |
58 | 59 |
59 void WorkerFileWriterCallbacksBridge::postWriteToMainThread(long long position,
const KURL& data) | 60 void WorkerFileWriterCallbacksBridge::postWriteToMainThread(long long position,
PassRefPtr<BlobDataHandle> blobDataHandle) |
60 { | 61 { |
61 ASSERT(!m_operationInProgress); | 62 ASSERT(!m_operationInProgress); |
62 m_operationInProgress = true; | 63 m_operationInProgress = true; |
63 dispatchTaskToMainThread(createCallbackTask(&writeOnMainThread, | 64 dispatchTaskToMainThread(createCallbackTask(&writeOnMainThread, |
64 this, position, data)); | 65 this, position, blobDataHandle))
; |
65 } | 66 } |
66 | 67 |
67 void WorkerFileWriterCallbacksBridge::postTruncateToMainThread(long long length) | 68 void WorkerFileWriterCallbacksBridge::postTruncateToMainThread(long long length) |
68 { | 69 { |
69 ASSERT(!m_operationInProgress); | 70 ASSERT(!m_operationInProgress); |
70 m_operationInProgress = true; | 71 m_operationInProgress = true; |
71 dispatchTaskToMainThread(createCallbackTask(&truncateOnMainThread, | 72 dispatchTaskToMainThread(createCallbackTask(&truncateOnMainThread, |
72 this, length)); | 73 this, length)); |
73 } | 74 } |
74 | 75 |
75 void WorkerFileWriterCallbacksBridge::postAbortToMainThread() | 76 void WorkerFileWriterCallbacksBridge::postAbortToMainThread() |
76 { | 77 { |
77 ASSERT(m_operationInProgress); | 78 ASSERT(m_operationInProgress); |
78 dispatchTaskToMainThread(createCallbackTask(&abortOnMainThread, this)); | 79 dispatchTaskToMainThread(createCallbackTask(&abortOnMainThread, this)); |
79 } | 80 } |
80 | 81 |
81 void WorkerFileWriterCallbacksBridge::postShutdownToMainThread(PassRefPtr<Worker
FileWriterCallbacksBridge> bridge) | 82 void WorkerFileWriterCallbacksBridge::postShutdownToMainThread(PassRefPtr<Worker
FileWriterCallbacksBridge> bridge) |
82 { | 83 { |
83 ASSERT(m_workerContext->isContextThread()); | 84 ASSERT(m_workerContext->isContextThread()); |
84 m_clientOnWorkerThread = 0; | 85 m_clientOnWorkerThread = 0; |
85 dispatchTaskToMainThread(createCallbackTask(&shutdownOnMainThread, bridge)); | 86 dispatchTaskToMainThread(createCallbackTask(&shutdownOnMainThread, bridge)); |
86 } | 87 } |
87 | 88 |
88 void WorkerFileWriterCallbacksBridge::writeOnMainThread(ScriptExecutionContext*,
PassRefPtr<WorkerFileWriterCallbacksBridge> bridge, long long position, const K
URL& data) | 89 void WorkerFileWriterCallbacksBridge::writeOnMainThread(ScriptExecutionContext*,
PassRefPtr<WorkerFileWriterCallbacksBridge> bridge, long long position, PassRef
Ptr<WebCore::BlobDataHandle> blobDataHandle) |
89 { | 90 { |
90 bridge->m_writer->write(position, WebURL(data)); | 91 bridge->m_writer->write(position, WebString(blobDataHandle->uuid())); |
91 } | 92 } |
92 | 93 |
93 void WorkerFileWriterCallbacksBridge::truncateOnMainThread(ScriptExecutionContex
t*, PassRefPtr<WorkerFileWriterCallbacksBridge> bridge, long long length) | 94 void WorkerFileWriterCallbacksBridge::truncateOnMainThread(ScriptExecutionContex
t*, PassRefPtr<WorkerFileWriterCallbacksBridge> bridge, long long length) |
94 { | 95 { |
95 bridge->m_writer->truncate(length); | 96 bridge->m_writer->truncate(length); |
96 } | 97 } |
97 | 98 |
98 void WorkerFileWriterCallbacksBridge::abortOnMainThread(ScriptExecutionContext*,
PassRefPtr<WorkerFileWriterCallbacksBridge> bridge) | 99 void WorkerFileWriterCallbacksBridge::abortOnMainThread(ScriptExecutionContext*,
PassRefPtr<WorkerFileWriterCallbacksBridge> bridge) |
99 { | 100 { |
100 bridge->m_writer->cancel(); | 101 bridge->m_writer->cancel(); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 WorkerContext* context = static_cast<WorkerContext*>(m_workerContext); | 216 WorkerContext* context = static_cast<WorkerContext*>(m_workerContext); |
216 if (context->thread()->runLoop().runInMode(context, m_mode) == MessageQu
eueTerminated) | 217 if (context->thread()->runLoop().runInMode(context, m_mode) == MessageQu
eueTerminated) |
217 return false; | 218 return false; |
218 } | 219 } |
219 return true; | 220 return true; |
220 } | 221 } |
221 | 222 |
222 } // namespace WebKit | 223 } // namespace WebKit |
223 | 224 |
224 #endif // ENABLE(FILE_SYSTEM) | 225 #endif // ENABLE(FILE_SYSTEM) |
OLD | NEW |