Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(801)

Side by Side Diff: Source/web/DatabaseObserver.cpp

Issue 50773002: Introduce WebWorkerPermissionClientProxy to deprecate WorkerAllowMainThreadBridge (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 23 matching lines...) Expand all
34 #include "WebCommonWorkerClient.h" 34 #include "WebCommonWorkerClient.h"
35 #include "WebDatabase.h" 35 #include "WebDatabase.h"
36 #include "WebDatabaseObserver.h" 36 #include "WebDatabaseObserver.h"
37 #include "WebFrameClient.h" 37 #include "WebFrameClient.h"
38 #include "WebFrameImpl.h" 38 #include "WebFrameImpl.h"
39 #include "WebPermissionClient.h" 39 #include "WebPermissionClient.h"
40 #include "WebSecurityOrigin.h" 40 #include "WebSecurityOrigin.h"
41 #include "WebViewImpl.h" 41 #include "WebViewImpl.h"
42 #include "WebWorkerBase.h" 42 #include "WebWorkerBase.h"
43 #include "WorkerAllowMainThreadBridgeBase.h" 43 #include "WorkerAllowMainThreadBridgeBase.h"
44 #include "WorkerPermissionClient.h"
44 #include "bindings/v8/WorkerScriptController.h" 45 #include "bindings/v8/WorkerScriptController.h"
45 #include "core/dom/CrossThreadTask.h" 46 #include "core/dom/CrossThreadTask.h"
46 #include "core/dom/Document.h" 47 #include "core/dom/Document.h"
47 #include "core/dom/ExecutionContext.h" 48 #include "core/dom/ExecutionContext.h"
48 #include "core/workers/WorkerGlobalScope.h" 49 #include "core/workers/WorkerGlobalScope.h"
49 #include "core/workers/WorkerLoaderProxy.h" 50 #include "core/workers/WorkerLoaderProxy.h"
50 #include "core/workers/WorkerThread.h" 51 #include "core/workers/WorkerThread.h"
51 #include "modules/webdatabase/DatabaseBackendBase.h" 52 #include "modules/webdatabase/DatabaseBackendBase.h"
52 #include "modules/webdatabase/DatabaseContext.h" 53 #include "modules/webdatabase/DatabaseContext.h"
53 #include "platform/CrossThreadCopier.h" 54 #include "platform/CrossThreadCopier.h"
54 55
55 using namespace WebKit; 56 using namespace WebKit;
56 57
57 namespace { 58 namespace {
58 59
59 static const char allowDatabaseMode[] = "allowDatabaseMode"; 60 static const char allowDatabaseMode[] = "allowDatabaseMode";
60 61
62 // FIXME: Deprecate this.
61 // This class is used to route the result of the WebWorkerBase::allowDatabase 63 // This class is used to route the result of the WebWorkerBase::allowDatabase
62 // call back to the worker context. 64 // call back to the worker context.
63 class AllowDatabaseMainThreadBridge : public WorkerAllowMainThreadBridgeBase { 65 class AllowDatabaseMainThreadBridge : public WorkerAllowMainThreadBridgeBase {
64 public: 66 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) 67 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 { 68 {
67 return adoptRef(new AllowDatabaseMainThreadBridge(workerGlobalScope, web WorkerBase, mode, frame, name, displayName, estimatedSize)); 69 return adoptRef(new AllowDatabaseMainThreadBridge(workerGlobalScope, web WorkerBase, mode, frame, name, displayName, estimatedSize));
68 } 70 }
69 71
70 private: 72 private:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return false; 123 return false;
122 } 124 }
123 125
124 return bridge->result(); 126 return bridge->result();
125 } 127 }
126 128
127 } 129 }
128 130
129 namespace WebCore { 131 namespace WebCore {
130 132
131 bool DatabaseObserver::canEstablishDatabase(ExecutionContext* executionContext, const String& name, const String& displayName, unsigned long estimatedSize) 133 bool DatabaseObserver::canEstablishDatabase(ExecutionContext* executionContext, const String& name, const String& displayName, unsigned long estimatedSize)
abarth-chromium 2013/10/30 06:49:03 It's really lame that we have this WebCore symbol
kinuko 2013/10/30 07:05:52 Totally agreed about this class shouldn't be imple
132 { 134 {
133 ASSERT(executionContext->isContextThread()); 135 ASSERT(executionContext->isContextThread());
134 ASSERT(executionContext->isDocument() || executionContext->isWorkerGlobalSco pe()); 136 ASSERT(executionContext->isDocument() || executionContext->isWorkerGlobalSco pe());
135 if (executionContext->isDocument()) { 137 if (executionContext->isDocument()) {
136 Document* document = toDocument(executionContext); 138 Document* document = toDocument(executionContext);
137 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); 139 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
138 if (!webFrame) 140 if (!webFrame)
139 return false; 141 return false;
140 WebViewImpl* webView = webFrame->viewImpl(); 142 WebViewImpl* webView = webFrame->viewImpl();
141 if (!webView) 143 if (!webView)
142 return false; 144 return false;
143 if (webView->permissionClient()) 145 if (webView->permissionClient())
144 return webView->permissionClient()->allowDatabase(webFrame, name, di splayName, estimatedSize); 146 return webView->permissionClient()->allowDatabase(webFrame, name, di splayName, estimatedSize);
145 } else { 147 } else {
146 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(executionCont ext); 148 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(executionCont ext);
149 WorkerPermissionClient* permissionClient = WorkerPermissionClient::from( workerGlobalScope);
150 if (permissionClient->proxy())
151 return permissionClient->allowDatabase(name, displayName, estimatedS ize);
152
153 // FIXME: Deprecate this bridge code when PermissionClientProxy is
154 // implemented by the embedder.
147 WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerGlobalScope ->thread()->workerLoaderProxy().toWebWorkerBase()); 155 WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerGlobalScope ->thread()->workerLoaderProxy().toWebWorkerBase());
148 WebView* view = webWorker->view(); 156 WebView* view = webWorker->view();
149 if (!view) 157 if (!view)
150 return false; 158 return false;
151 return allowDatabaseForWorker(view->mainFrame(), name, displayName, esti matedSize); 159 return allowDatabaseForWorker(view->mainFrame(), name, displayName, esti matedSize);
152 } 160 }
153 161
154 return true; 162 return true;
155 } 163 }
156 164
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 { 204 {
197 WebDatabase::observer()->reportExecuteStatementResult(WebDatabase(database), errorSite, webSqlErrorCode, sqliteErrorCode); 205 WebDatabase::observer()->reportExecuteStatementResult(WebDatabase(database), errorSite, webSqlErrorCode, sqliteErrorCode);
198 } 206 }
199 207
200 void DatabaseObserver::reportVacuumDatabaseResult(DatabaseBackendBase* database, int sqliteErrorCode) 208 void DatabaseObserver::reportVacuumDatabaseResult(DatabaseBackendBase* database, int sqliteErrorCode)
201 { 209 {
202 WebDatabase::observer()->reportVacuumDatabaseResult(WebDatabase(database), s qliteErrorCode); 210 WebDatabase::observer()->reportVacuumDatabaseResult(WebDatabase(database), s qliteErrorCode);
203 } 211 }
204 212
205 } // namespace WebCore 213 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/web/IDBFactoryBackendProxy.cpp » ('j') | Source/web/WebSharedWorkerImpl.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698