OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // --> MainThreadStorageQuotaCallbacks::didXxx is called on MainThread | 65 // --> MainThreadStorageQuotaCallbacks::didXxx is called on MainThread |
66 // --> Bridge::didXxxOnMainThread is called on MainThread | 66 // --> Bridge::didXxxOnMainThread is called on MainThread |
67 // --> Bridge::didXxxOnWorkerThread is called on WorkerThread | 67 // --> Bridge::didXxxOnWorkerThread is called on WorkerThread |
68 // This calls the original callbacks (m_callbacksOnWorkerThread). | 68 // This calls the original callbacks (m_callbacksOnWorkerThread). |
69 class WorkerStorageQuotaCallbacksBridge : public ThreadSafeRefCounted<WorkerStor
ageQuotaCallbacksBridge> { | 69 class WorkerStorageQuotaCallbacksBridge : public ThreadSafeRefCounted<WorkerStor
ageQuotaCallbacksBridge> { |
70 public: | 70 public: |
71 ~WorkerStorageQuotaCallbacksBridge(); | 71 ~WorkerStorageQuotaCallbacksBridge(); |
72 | 72 |
73 void stop(); | 73 void stop(); |
74 | 74 |
75 static PassRefPtr<WorkerStorageQuotaCallbacksBridge> create(WebCore::WorkerL
oaderProxy* workerLoaderProxy, WebCore::ScriptExecutionContext* workerContext, W
ebStorageQuotaCallbacksImpl* callbacks) | 75 static PassRefPtr<WorkerStorageQuotaCallbacksBridge> create(WebCore::WorkerL
oaderProxy* workerLoaderProxy, WebCore::ScriptExecutionContext* workerGlobalScop
e, WebStorageQuotaCallbacksImpl* callbacks) |
76 { | 76 { |
77 return adoptRef(new WorkerStorageQuotaCallbacksBridge(workerLoaderProxy,
workerContext, callbacks)); | 77 return adoptRef(new WorkerStorageQuotaCallbacksBridge(workerLoaderProxy,
workerGlobalScope, callbacks)); |
78 } | 78 } |
79 | 79 |
80 // Entry method to post QueryUsageAndQuota task to main thread. | 80 // Entry method to post QueryUsageAndQuota task to main thread. |
81 void postQueryUsageAndQuotaToMainThread(WebCommonWorkerClient*, WebStorageQu
otaType, const String& mode); | 81 void postQueryUsageAndQuotaToMainThread(WebCommonWorkerClient*, WebStorageQu
otaType, const String& mode); |
82 | 82 |
83 // Callback methods that are called on the main thread. | 83 // Callback methods that are called on the main thread. |
84 void didFailOnMainThread(WebStorageQuotaError, const String& mode); | 84 void didFailOnMainThread(WebStorageQuotaError, const String& mode); |
85 void didQueryStorageUsageAndQuotaOnMainThread(unsigned long long usageInByte
s, unsigned long long quotaInBytes, const String& mode); | 85 void didQueryStorageUsageAndQuotaOnMainThread(unsigned long long usageInByte
s, unsigned long long quotaInBytes, const String& mode); |
86 | 86 |
87 private: | 87 private: |
(...skipping 11 matching lines...) Expand all Loading... |
99 static void didQueryStorageUsageAndQuotaOnWorkerThread(WebCore::ScriptExecut
ionContext*, PassRefPtr<WorkerStorageQuotaCallbacksBridge>, unsigned long long u
sageInBytes, unsigned long long quotaInBytes); | 99 static void didQueryStorageUsageAndQuotaOnWorkerThread(WebCore::ScriptExecut
ionContext*, PassRefPtr<WorkerStorageQuotaCallbacksBridge>, unsigned long long u
sageInBytes, unsigned long long quotaInBytes); |
100 | 100 |
101 void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Ta
sk>); | 101 void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Ta
sk>); |
102 void mayPostTaskToWorker(PassOwnPtr<WebCore::ScriptExecutionContext::Task>,
const String& mode); | 102 void mayPostTaskToWorker(PassOwnPtr<WebCore::ScriptExecutionContext::Task>,
const String& mode); |
103 | 103 |
104 void cleanUpAfterCallback(); | 104 void cleanUpAfterCallback(); |
105 | 105 |
106 Mutex m_loaderProxyMutex; | 106 Mutex m_loaderProxyMutex; |
107 WebCore::WorkerLoaderProxy* m_workerLoaderProxy; | 107 WebCore::WorkerLoaderProxy* m_workerLoaderProxy; |
108 | 108 |
109 WebCore::ScriptExecutionContext* m_workerContext; | 109 WebCore::ScriptExecutionContext* m_workerGlobalScope; |
110 | 110 |
111 // Must be deleted on the WorkerContext thread. | 111 // Must be deleted on the WorkerGlobalScope thread. |
112 WorkerStorageQuotaContextObserver* m_workerContextObserver; | 112 WorkerStorageQuotaContextObserver* m_workerGlobalScopeObserver; |
113 | 113 |
114 // This is self-destructed and must be fired on the worker thread. | 114 // This is self-destructed and must be fired on the worker thread. |
115 WebStorageQuotaCallbacksImpl* m_callbacksOnWorkerThread; | 115 WebStorageQuotaCallbacksImpl* m_callbacksOnWorkerThread; |
116 }; | 116 }; |
117 | 117 |
118 } // namespace WebCore | 118 } // namespace WebCore |
119 | 119 |
120 #endif // WorkerStorageQuotaCallbacksBridge_h | 120 #endif // WorkerStorageQuotaCallbacksBridge_h |
OLD | NEW |