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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 using namespace WebKit; | 55 using namespace WebKit; |
56 | 56 |
57 namespace { | 57 namespace { |
58 | 58 |
59 static const char allowDatabaseMode[] = "allowDatabaseMode"; | 59 static const char allowDatabaseMode[] = "allowDatabaseMode"; |
60 | 60 |
61 // This class is used to route the result of the WebWorkerBase::allowDatabase | 61 // This class is used to route the result of the WebWorkerBase::allowDatabase |
62 // call back to the worker context. | 62 // call back to the worker context. |
63 class AllowDatabaseMainThreadBridge : public WorkerAllowMainThreadBridgeBase { | 63 class AllowDatabaseMainThreadBridge : public WorkerAllowMainThreadBridgeBase { |
64 public: | 64 public: |
65 static PassRefPtr<AllowDatabaseMainThreadBridge> create(WebCore::WorkerGloba
lScope* workerGlobalScope, WebWorkerBase* webWorkerBase, const String& mode, Web
Frame* frame, const String& name, const String& displayName, unsigned long estim
atedSize) | 65 static PassRefPtr<AllowDatabaseMainThreadBridge> create(WebCore::WorkerGloba
lScope& workerGlobalScope, WebWorkerBase* webWorkerBase, const String& mode, Web
Frame* frame, const String& name, const String& displayName, unsigned long estim
atedSize) |
66 { | 66 { |
67 return adoptRef(new AllowDatabaseMainThreadBridge(workerGlobalScope, web
WorkerBase, mode, frame, name, displayName, estimatedSize)); | 67 return adoptRef(new AllowDatabaseMainThreadBridge(workerGlobalScope, web
WorkerBase, mode, frame, name, displayName, estimatedSize)); |
68 } | 68 } |
69 | 69 |
70 private: | 70 private: |
71 class AllowDatabaseParams : public AllowParams | 71 class AllowDatabaseParams : public AllowParams |
72 { | 72 { |
73 public: | 73 public: |
74 AllowDatabaseParams(const String& mode, WebFrame* frame, const String& n
ame, const String& displayName, unsigned long estimatedSize) | 74 AllowDatabaseParams(const String& mode, WebFrame* frame, const String& n
ame, const String& displayName, unsigned long estimatedSize) |
75 : AllowParams(mode) | 75 : AllowParams(mode) |
76 , m_frame(WebCore::AllowCrossThreadAccess(frame)) | 76 , m_frame(WebCore::AllowCrossThreadAccess(frame)) |
77 , m_name(name.isolatedCopy()) | 77 , m_name(name.isolatedCopy()) |
78 , m_displayName(displayName.isolatedCopy()) | 78 , m_displayName(displayName.isolatedCopy()) |
79 , m_estimatedSize(estimatedSize) | 79 , m_estimatedSize(estimatedSize) |
80 { | 80 { |
81 } | 81 } |
82 WebCore::AllowCrossThreadAccessWrapper<WebFrame> m_frame; | 82 WebCore::AllowCrossThreadAccessWrapper<WebFrame> m_frame; |
83 String m_name; | 83 String m_name; |
84 String m_displayName; | 84 String m_displayName; |
85 unsigned long m_estimatedSize; | 85 unsigned long m_estimatedSize; |
86 }; | 86 }; |
87 | 87 |
88 AllowDatabaseMainThreadBridge(WebCore::WorkerGlobalScope* workerGlobalScope,
WebWorkerBase* webWorkerBase, const String& mode, WebFrame* frame, const String
& name, const String& displayName, unsigned long estimatedSize) | 88 AllowDatabaseMainThreadBridge(WebCore::WorkerGlobalScope& workerGlobalScope,
WebWorkerBase* webWorkerBase, const String& mode, WebFrame* frame, const String
& name, const String& displayName, unsigned long estimatedSize) |
89 : WorkerAllowMainThreadBridgeBase(workerGlobalScope, webWorkerBase) | 89 : WorkerAllowMainThreadBridgeBase(&workerGlobalScope, webWorkerBase) |
90 { | 90 { |
91 postTaskToMainThread( | 91 postTaskToMainThread( |
92 adoptPtr(new AllowDatabaseParams(mode, frame, name, displayName, est
imatedSize))); | 92 adoptPtr(new AllowDatabaseParams(mode, frame, name, displayName, est
imatedSize))); |
93 } | 93 } |
94 | 94 |
95 virtual bool allowOnMainThread(WebCommonWorkerClient* commonClient, AllowPar
ams* params) | 95 virtual bool allowOnMainThread(WebCommonWorkerClient* commonClient, AllowPar
ams* params) |
96 { | 96 { |
97 ASSERT(isMainThread()); | 97 ASSERT(isMainThread()); |
98 AllowDatabaseParams* allowDBParams = static_cast<AllowDatabaseParams*>(p
arams); | 98 AllowDatabaseParams* allowDBParams = static_cast<AllowDatabaseParams*>(p
arams); |
99 return commonClient->allowDatabase( | 99 return commonClient->allowDatabase( |
100 allowDBParams->m_frame.value(), allowDBParams->m_name, allowDBParams
->m_displayName, allowDBParams->m_estimatedSize); | 100 allowDBParams->m_frame.value(), allowDBParams->m_name, allowDBParams
->m_displayName, allowDBParams->m_estimatedSize); |
101 } | 101 } |
102 }; | 102 }; |
103 | 103 |
104 bool allowDatabaseForWorker(WebFrame* frame, const WebString& name, const WebStr
ing& displayName, unsigned long estimatedSize) | 104 bool allowDatabaseForWorker(WebFrame* frame, const WebString& name, const WebStr
ing& displayName, unsigned long estimatedSize) |
105 { | 105 { |
106 WebCore::WorkerScriptController* controller = WebCore::WorkerScriptControlle
r::controllerForContext(); | 106 WebCore::WorkerScriptController* controller = WebCore::WorkerScriptControlle
r::controllerForContext(); |
107 WebCore::WorkerGlobalScope* workerGlobalScope = controller->workerGlobalScop
e(); | 107 WebCore::WorkerGlobalScope& workerGlobalScope = controller->workerGlobalScop
e(); |
108 WebCore::WorkerThread* workerThread = workerGlobalScope->thread(); | 108 WebCore::WorkerThread* workerThread = workerGlobalScope.thread(); |
109 WebCore::WorkerRunLoop& runLoop = workerThread->runLoop(); | 109 WebCore::WorkerRunLoop& runLoop = workerThread->runLoop(); |
110 WebCore::WorkerLoaderProxy* workerLoaderProxy = &workerThread->workerLoaderP
roxy(); | 110 WebCore::WorkerLoaderProxy* workerLoaderProxy = &workerThread->workerLoaderP
roxy(); |
111 | 111 |
112 // Create a unique mode just for this synchronous call. | 112 // Create a unique mode just for this synchronous call. |
113 String mode = allowDatabaseMode; | 113 String mode = allowDatabaseMode; |
114 mode.append(String::number(runLoop.createUniqueId())); | 114 mode.append(String::number(runLoop.createUniqueId())); |
115 | 115 |
116 RefPtr<AllowDatabaseMainThreadBridge> bridge = AllowDatabaseMainThreadBridge
::create(workerGlobalScope, workerLoaderProxy->toWebWorkerBase(), mode, frame, n
ame, displayName, estimatedSize); | 116 RefPtr<AllowDatabaseMainThreadBridge> bridge = AllowDatabaseMainThreadBridge
::create(workerGlobalScope, workerLoaderProxy->toWebWorkerBase(), mode, frame, n
ame, displayName, estimatedSize); |
117 | 117 |
118 // Either the bridge returns, or the queue gets terminated. | 118 // Either the bridge returns, or the queue gets terminated. |
119 if (runLoop.runInMode(workerGlobalScope, mode) == MessageQueueTerminated) { | 119 if (runLoop.runInMode(&workerGlobalScope, mode) == MessageQueueTerminated) { |
120 bridge->cancel(); | 120 bridge->cancel(); |
121 return false; | 121 return false; |
122 } | 122 } |
123 | 123 |
124 return bridge->result(); | 124 return bridge->result(); |
125 } | 125 } |
126 | 126 |
127 } | 127 } |
128 | 128 |
129 namespace WebCore { | 129 namespace WebCore { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 { | 196 { |
197 WebDatabase::observer()->reportExecuteStatementResult(WebDatabase(database),
errorSite, webSqlErrorCode, sqliteErrorCode); | 197 WebDatabase::observer()->reportExecuteStatementResult(WebDatabase(database),
errorSite, webSqlErrorCode, sqliteErrorCode); |
198 } | 198 } |
199 | 199 |
200 void DatabaseObserver::reportVacuumDatabaseResult(DatabaseBackendBase* database,
int sqliteErrorCode) | 200 void DatabaseObserver::reportVacuumDatabaseResult(DatabaseBackendBase* database,
int sqliteErrorCode) |
201 { | 201 { |
202 WebDatabase::observer()->reportVacuumDatabaseResult(WebDatabase(database), s
qliteErrorCode); | 202 WebDatabase::observer()->reportVacuumDatabaseResult(WebDatabase(database), s
qliteErrorCode); |
203 } | 203 } |
204 | 204 |
205 } // namespace WebCore | 205 } // namespace WebCore |
OLD | NEW |